Table of content

Switch Control Action

The switch is a control action designed to find a match for a certain value. It's not a logical statement. It only compares if the value is equal to something and when it finds a match then it takes action on a separate branch.

If you know some other programming languages then condition control action is nothing but switch statements.

For example, if we received an order and the order has different categories like Electronics, Seasonal, and Health. The requirement is that if the category is Electronics then it goes to Expedited Shipping, if it's Seasonal it goes in Cargo and Health goes in DHL.
flowchart-switch-power-automate

Creating the Switch action flow in power automate

  • Let's get back to the previous condition flow. Click on the New step.
    new-step-switch-power-automate
  • Select Initialize variable from actions. Create a variable name ShippingMethod of type String. Click on the New step.
    shipping-method-swich-power-automate
  • Select Switch (Control) from actions.
    switch-control-action-power-automate
  • As we are performing actions for Category. Add Category from dynamic content.
    switch-catagory-power-automate
  • Select Set Variable from actions. For the first case, we have Electronics. Choose ShippingMethod as a variable and enter the value Expediated.
    switchcase1-power-automate
  • Similarly, enter values for Seasonal, Health, and Default case. If there is no category matching with the variable value the Default case will be executed.
    switchcase2-power-automate
    switchcase3-power-automate
    switchcase4-power-automate
  • Add Compose(Data Operation) from actions. Add ShippingMethod variable from dynamic content. Click on Save.
    compose-switchcase-power-automate
  • Click on Test. Enter the values in Order item, Category, Amount. Click on Run flow.
    runflow-switchcase1-powerautomate
  • Click on Compose to see the Output. Here, it's showing the output as Expediated which is associated with the Electronics category. Similarly, you can do it for other categories as well.
    output1-switchcase1-power-automate
  • For default case, if you enter any other category. It will show you the default output.
    default-switchcase-power-automate
  • Here, it's showing Ground Shipping as our output with the default case.
    compose-swtichcase-default-power-automate

This was all about Switch control action in Microsoft Power Automate.

0 results
Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions