Skip to main content
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

6 Replies
sunny_talwar

May be this

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

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

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

Anil_Babu_Samineni

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

You would need this for Pick Match....

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

Anil_Babu_Samineni

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

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

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