Hello - I need to write conditional statements based on certain characters in a string.
For example, If the 1st character is "D" AND 4th Character is L or S or F or Z THEN "Kansas"
Also something similar but
If the 4th character is "D" AND 6th Character is L or S or F or Z THEN "Kansas"
How would I write this?
Thank you!
Solved! Go to Solution.
Hi @pacbloyd,
You could use:
IF StartsWith([String], 'D') AND Substring([String],3,1) IN('L','S','F','Z')
THEN 'Kansas' ELSE ''
ENDIF
I've attached my workflow for you to download if needed!
Kind regards,
Jonathan
Thanks @Jonathan-Sherman, and what about a case where the conditional depended on the 4th character? I assume StartsWith won't work?
It's worth noting the SubString() function indexes from 0, so to search the 4th character you'll want to start from 3 rather than 4, can catch people out!
Could you give an example?
Sure - we can use the same letters, but say it depends on what the 4th character is? I edited my OP to include an example
You could just go with two SubString() functions:
IF Substring([String],3,1) = 'D' AND Substring([String],5,1) IN('L','S','F','Z')
THEN 'Kansas' ELSE ''
ENDIF
Kind regards,
Jonathan