Switch expression contains does not work

Hello, there’s an error with my contains expression on the switch activity.

This is my switch expression
If(paymentType.Contains("CASH "), "CASH “, If(paymentType.Contains(“SINGAPORE POST LIMITED”), “SINGAPORE POST LIMITED”, If(paymentType.Contains(“AXS”), “AXS”, If(paymentType.Contains(” CHEQUE "), " CHEQUE ", “Default”))))

This is the excel table where I am looking for the words that contains the specific words

image

Only two of the contains are working. Which are “SINGAPORE POST LIMITED” and “AXS”, “CASH” and “CHEQUE” are not working. I do not know why the other two is not able to work.

Thanks in advance!

@kieranwong

Hi,
I don’t think that switch will work with IF’s :wink:
Switch expression works as single value checker, so imagine that you are having variable “fruit” and this variable can have various values like “orange” or “apple” or “banana” etc… by swtich you are refering to variable: fruit and as a case you are using “orange”

example:
image

This is where I got the idea of using IF function in switch.

This is new for me :smiley: thanks for a lesson, ok so basically you can try this statement:
If(paymentType.Contains(“CASH”), “CASH“, If(paymentType.Contains(“SINGAPORE POST LIMITED”), “SINGAPORE POST LIMITED”, If(paymentType.Contains(“AXS”), “AXS”, If(paymentType.Contains(”CHEQUE”), “CHEQUE”, “Default”))))

Basicaly remove spaces while you are creating new value

2 Likes

Thank you! it works now

You are welcome :slight_smile:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.