Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

If Else expression

Hello

I have an expression which goes like this

=

If(A like 'B', 'B',

If(A like 'C*', 'C',

If(A like 'D*', 'D',

null())))

But I want to change it to also give a title to all other possible entries

So something like this

=

If(A like 'B', 'B',

If(A like 'C*', 'C',

If(A like 'D*', 'D',

Else ('E',

null()))))

So if A isnt like B,C or D it is presented as E

If there is a way to do this it would be appreciated

Labels (1)
6 Replies
sunny_talwar
MVP
MVP

May be this

=If(A like 'B', 'B',

If(A like 'C*', 'C',

If(A like 'D*', 'D', 'E')))

Anil_Babu_Samineni
MVP
MVP

Try this?

Pick(Match(A, 'B', 'C*', 'D*'), 'B','C','D', 'E')

OR

If(Match(A, 'B'), 'B',

If(Match(A, 'C*'), 'C',

If(Match(A, 'D*'), 'D', 'E')))


Note - I am not sure i understand about Null() part

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
sunny_talwar
MVP
MVP

You would need this for Pick Match....

Pick(WildMatch(A, 'B', 'C*', 'D*') + 1, 'E', 'B','C','D')

Anil_Babu_Samineni
MVP
MVP

WildMatch is good one, But what does the use of +1 here?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
sunny_talwar
MVP
MVP

Basically

when A = B, WildMatch will give 1 + 1 = 2

when A = C*, WildMatch will give 2 + 1 = 3

when A = D*, WildMatch will give 3 + 1 = 4

when A = E, WildMatch will give 0 + 1 = 1

The way you wrote the expression, for E to show up, its value needs to be 4, but E can never equal 4, so its better to put it as the first clause....

Does that make sense?

Anil_Babu_Samineni
MVP
MVP

Yes, LOT sense now. May be i miss this concept. I need to endorse this part. Thanks Bhai

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful