Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Clarification on if-then statement in load script

Hi guys. Quick question. I want to create a derived field on top of one of my tables using an if statement.

If I want to do something of the sort like this: if FieldA = {'A','B','C'}, I have had to write it all out like if(FieldA = 'A' OR FieldA = 'B' OR FieldA = 'C', ...)

Is there an easy way to combine them into a set rather than expanding it all out using ORs?

Cheers,

Eric

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

Yep:

if(match(FieldA,'A','B','C'),...)

And while it doesn't matter here, the match() function returns the position in the list of the first match. So if FieldA = 'B', it will return 2. If it matches nothing, it returns 0. That's sometimes useful.

View solution in original post

1 Reply
johnw
Champion III
Champion III

Yep:

if(match(FieldA,'A','B','C'),...)

And while it doesn't matter here, the match() function returns the position in the list of the first match. So if FieldA = 'B', it will return 2. If it matches nothing, it returns 0. That's sometimes useful.