unkoqn
unkoqn

Reputation: 43

Microsoft Power Automate Switch case

So what I'm trying to replicate is the following,

   string str = GetInput from Form();

   switch (str)
   {
      case "1":
      case "1 week":
          assign variable = 1
          Insert variable to excel column
          break;
      case "2":
      case "2 weeks":
          assign variable = 3
          Insert variable to excel column
      case "4":
      case "4 weeks":
          assign variable = 4
          Insert variable to excel column
      default:
          assign variable = 0
          Insert variable to excel column
          break;
  }

Currently, my flow is similar to the following diagram

Flow

  1. When a new response is submitted
  2. Get response details
  3. Create item action (Run the above switch case condition using a power automate - functions)

Upvotes: 1

Views: 4261

Answers (1)

Gandalf
Gandalf

Reputation: 2417

You are using an Apply for Each control in your flow which is equivalent to a For loop in normal programming language. You need to use Switch control for your problem as shown in image below. I have used a sample string parameter to show the usage of switch statement, but if your data is coming from an array you can apply Switch inside Apply for Each loop.

Read this article for step by step guide.

enter image description here

Upvotes: 1

Related Questions