Switch-Case in a Flow | Power Automate

Some of the common operations / decision making one wants to perform in terms of programming is definitely switch-case!

Here’s how you can do it in power automate

Scenario

To keep things simple, I will simply reflect the name of the OptionSet value in a variable in Flow –

    1. Here’s my OptionSet called Account Type with values Customer [1], Vendor [2] & Partner [3]
      optionSet

 

    1. My Flow will be called on update of Account record’s Account Type field change
      updateOfAccountType

 

    1. I’m simply using a variable to store the value of the selection made on the field.
      initVariable

 

Using Switch

Now, let’s get to the important part –

    1. If you search for Switch under Control, you’ll see as below
      switchControl

 

    1. This will first ask you what the Switch should be on, in this case, it’s the Account Type value to be selected from the dynamics values
      accountTypeChosen

 

    1. Now, I can start entering the Cases one by one as shown below and setting the variable I created above. For value in Equals 1, I’ll set variable as Customer
      firstCase&Default
      case1DetClicking on the + [Plus] sign in between Case and Default will let you add more cases.
      addCase

 

    1. Finally, once all the cases are entered, the Flow will start looking something like this from a hawk-eye-view with the Default case appearing in the end.
      hawkEye

 

Working

Let’s look at how Switch-Case would work –

    1. I updated the Account Type field with Vendor
      d365Updated

 

    1. Switch on the Account Type Value (selected from Dynamic Values) will reflect the value of 2
      2Selected

 

    1. And Case 2 will execute simply reflecting what is stored in the variable. Rest of the cases will not run
      result

 

Pretty Easy! Hope this helps!