Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
stuwannop
Partner - Creator III
Partner - Creator III

Create a Flag Based on a Text String

Hi Everyone

Wondering if you could help with this. I have a field in a data table that may or may not contain the string "SORD". This could be anywhere in the text string.

What I'd like to be able to do is create a flag (1 or 0) as a new field depending on whether the text string SORD exists in the field. I can do it in Excel but can't get it working in Qlik!

Thanks in advance

Stu

1 Solution

Accepted Solutions
jagan
Luminary Alumni
Luminary Alumni


Hi,

Try WildMatch() or substringcount().  Check help file for examples.

LOAD

*,

If(substringcount(Dimension, 'SORD')>0, 1, 0) as Flag

FROM DataSource;

OR

LOAD

*,

If(WildMatch(Dimension, '*SORD*')>0, 1, 0) as Flag

FROM DataSource;

Regadrs,

Jagan.

View solution in original post

3 Replies
jagan
Luminary Alumni
Luminary Alumni


Hi,

Try WildMatch() or substringcount().  Check help file for examples.

LOAD

*,

If(substringcount(Dimension, 'SORD')>0, 1, 0) as Flag

FROM DataSource;

OR

LOAD

*,

If(WildMatch(Dimension, '*SORD*')>0, 1, 0) as Flag

FROM DataSource;

Regadrs,

Jagan.

tresesco
MVP
MVP

Try like:

If(SubStringCount(YourField, 'SORD')>0, 1, 0) as Flag

stuwannop
Partner - Creator III
Partner - Creator III
Author

Marvellous - thanks to both of you that works a treat!

Have a good day.

Stu