Showing results for 
Search instead for 
Did you mean: 
Helper III
Helper III

Variable reference in Switch Case parsed as string literal. Even with '@' sign appended.

I have a very complex flow with 70 branches formed from nested switch cases and need a way to populate the switch case string from a variable declared upstream in the flow. To date I have managed this manually by typing the string literals into every case (slow) but this is intolerant to changes upstream.


Image 1: this is what I have x 70:Screen Shot 2021-03-23 at 10.14.22 am.png


Image 2: this is what I need to allow changes in case to be managed for all forks in the flow:


Screen Shot 2021-03-23 at 10.15.21 am.png


But variables('keywordType')[0] is being parsed as a string literal not a variable reference. Appending '@' throws the following error:


Screen Shot 2021-03-23 at 10.54.12 am.png


'The template action 'my switch name' at line '1' and column '9117' is not valid: the value '@@variables('keywordType')[0]' specified for 'case' property in switch case 'my case name' contains expressions that are not supported. Only a literal of type string or interger or a '@parameters()' expression can be specified for the 'case' property.'   complete with Microsoft Typo.

In other words the '@' is appended by the system, but still deemed a string literal.


Is there some syntax I'm missing here? Or is it not possible to reference a variable in the case of a switch case? That would be crazy I would have thought, particularly as the error states: '@parameters()' expression can be specified .


Any clue greatly appreciated!

Community Support
Community Support



Looking at the error it does say that the expression can be used but its not allowing yours to be used. It looks like it should work but I'm personally not sure why its not. This might be something that Microsoft will need to delve a bit farther into. I'll pass this on but I would also encourage you to open a ticket on this if you would like to track this. I'll include a link below if you would like to do so.


If you would like to create a ticket with Microsoft Customer Support here is a link on how to do so:








Community Support Team _ Alex Rezac
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helper I
Helper I

Any luck with getting this to work? I also need to use a variable in a case for a switch and can't get it to work.  Getting the same error as you posted above, @HydrogenUtility .


No. It doesn’t work. Final response from MS variables are not supported in switch statements.

Documentation is not up to date and the error message is generic. 
I completely redesigned my flow and eliminated switch altogether opting instead to populate all variables based on a single top level variables and runtime loading of an excel table. 
Turned out to be a much better solution and entirely scalable. 
Good luck on your flow building.

Thank you! This is helpful to know.

Helpful resources

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (2,913)