Use variables on case of a switch


I might missed something, because my string doesn’t equal the other string.

which mystring1 = “19/04/2019” and mystring2 = “19/04/2019”

but if i do mystring1 = “19/04/2019” direcltly it works?

I’m using two variable, for this purpose they have the same value. so why when i try mystring1 = mystring2 doesn’t work? btw on a switch

i mean it doesn’t choose the correct case

but works with if condition…

1 Like

With switches the cases can’t be variables but instead arguments, hence why it doesn’t work when you put the name of the variable in because it sees it as a string. But it will work when you 19/04/2019 as a string as the case.


Can i have a view on the switch case if possible a screenshot and the variable mystring1 declaration as well
Try to mention the value in the case without double quotes
that would be the issue i guess as it should work for sure
Cheers @mz3bel

1 Like

You are right, it takes it with double quotes

1 Like

Hi @Palaniyappan

I can show code sorry, i know the issue now it’s the double quotes, but i can’t put the value directly because it’s changes. I have to use variables…

yes of course we can use variables in cases, but make sure that the type argument is changed as string in the switch activity property panel
Cheers @mz3bel

Yes, it is, and both variables too

1 Like

So were you now able to get that working
Cheers @mz3bel

Actualy no, that’s what i ve done before. I must defently missed something

both the expression and cases are variables

1 Like

You may want to consider this:


Fine usually i hope we give only in case where the expression has the variable or arguments…so that could be the issue, I tried to reproduce this issue from side, variable in the case didn’t work, only value when passed to case it works…i tried to figure out whether it is correct or not in microsoft docs as well

while with variable

So i would suggest you have the expression with the variables and create n number of cases with the value that you feelwill reflect (as you said the value might change)

Cheers @mz3bel

1 Like

Ok, i’m trying this way

I’ll try this way too, if i don’t succed i will find an other way

1 Like

So it worked for me, i did this

If(myVar.Contains(myVar1),“myVar1”, If(myVar.Contains(myVar2),“myVar2”, If(myVar.Contains(myVar3),“myVar3”, If(myVar.Contains(myVar4),“myVar4”, “Default”))))

So for those who wants to use variable on case switch, use this… :arrow_up:

Big thanks to @Ellboy and @Palaniyappan


Cheers @mz3bel

1 Like

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