Evaluate a field for a -

I’m trying to evaluate the ITEM_NUMBER field for containing a dash ‘-’ and label those containing a dash one type and those without a dash another type. I would like to do this in the display stage.

I’m trying to get a regexp() statement to work for this but not having success. I only see this available in the filter stage.

If I go this route, I have to create two widgets one for each type.

Has anyone done something like this?
I do see there is a regexpMatch() but not finding any documentation on it…is this what I’m looking for?

Thanks!

If I understood… you want to differentiate items with dash and without dash.
You can use condition logic. Bring every item number with or without dash ‘-‘.
Creat a display column called ‘ITMTYP’
condition(equals(fibdSubstring(ITEM_NUMBER,”-“,0,20),0,1),”WITH DASH”,”NO DASH”)

1 Like

Hello,

That logic is exactly how this would need to be addressed!

To take it one step further, you can change the condition to the following to account for a dash existing at any part of the item_number: condition(greaterThanOrEqual(findSubstring(ITEM_NUMBER,"-",0,20),0),“WITH DASH”,“NO DASH”)

Let’s look at the elements individually:

findSubstring(ITEM_NUMBER,"-",0,20): This looks for a dash within the first and twentieth character of the string. If you have long strings, you might need to change 20 for a greather number.

greaterThanOrEqual([…],0) : This is used to evaluate the value returned by the inner statement. If a substring is found, the return value will be 0 and if it isn’t, it would be -1. We added it here to handle cases where the dash would be the first character in the string.

condition([…],“WITH DASH”,“NO DASH”): This is the part that separates the data under two different columns depending on whether they evaluate to true or false.

Thank you
Don’t hesitate to reach out if you have any further questions!

Thank you!

Thank you for the reply! This helps!

Just to circle back to the original syntax you mentioned, you were onto the most dynamic option. It does not require any starting or ending positions within the search:

condition(equals(regexMatch(ITEM_NUMBER,"-"),true),“DASH”,“NO DASH”)

OR

condition(regexMatch(ITEM_NUMBER,"-"),“DASH”,“NO DASH”)

Thank you!