Describe loops and conditions including switch, do until, and apply to each
In its simplest form, a Power Automate flow consists of a series of steps performed in sequence, one trigger, and at least one action. When the last action is completed, the processing of the flow ends. However, it is possible to create more complex flows that take nonlinear paths, such as those that contain conditional branching or processing loops.
Conditional flows
A flow can contain a condition, which is an if/then statement that defines two possible actions. For example, an automated flow can contain a trigger that causes it to run whenever a new email arrives in a specific mailbox. A Condition action can then check whether the email message was sent with high importance, as shown in Figure 5-17. The Condition step then branches into two possible actions: the If yes action if the message was sent with high importance and the If no action if it was not. The If yes action can cause a notification to be sent to the user’s smartphone, and the If no action does nothing.

FIGURE 5-17 A Condition branch in an automated flow
To create a conditional branch, the developer creates a new step and, in the Choose an action dialog box, clicks the Built-in tab and selects the Condition action, as shown in Figure 5-18.

FIGURE 5-18 Built-in actions in the Choose an action dialog box
The Condition action is one way to create branching actions in the Power Automate flow; another is the Switch action, which is a conditional action that determines which of multiple cases to execute based on the input fed to the switch. The advantage of the Switch action over the Condition action is that though Condition is limited to two branches (Yes and No), the Switch action can have as many cases as are needed.
For example, the flow in Figure 5-19 contains an action that determines the day of the week, which is then followed by a Switch action that contains cases named for days of the week. Each case can then contain actions specific to that day.

FIGURE 5-19 The Switch action with three cases