Branching is a fundamental control structure that lets your program make decisions depending on certain conditions. In Power Automate, you can utilize the Control, called “Condition” to include branches. With the use of it, different actions can be performed based on whether the condition is true or false, creating a sense of decision-making for the software.
Here’s a quick example where we’re checking if a number is greater than 10:
Condition: Number is greater than 10
Yes: Show “Number is greater than 10”
No: Show “Number is less than 10"
Loops
Loops allow the execution of a sequence of instructions multiple times until a certain condition is met. In the Microsoft Power Platform, loops are implemented using the “Apply to each” control in Power Automate.
Here’s a simple instance of a loop that iterates through an array of numbers and displays each number:
Array: 1, 2, 3, 4, 5
Apply to each item in Array
Show item
Conditions
Conditional statements are used to perform different actions based on whether a specific condition is true or false. You can use the “Condition” control in Power Automate to implement conditions easily.
Here’s a simple condition that checks if a variable is true:
Condition: Variable is true
Yes: Show “Variable is true”
No: Show “Variable is false”
Error Handling
Error handling is used to respond to exceptions (i.e., errors) that occur when your program is running. In Microsoft Power Platform, you can configure error handling by using the “Configure run after” setting in Power Automate. You can set certain actions to happen after fail, success, skip, or regardless of failure.
Variables
Variables are essentially containers for storing data values. In Power Automate, variables are used across different actions. You can set a variable using the “Initialize variable” action, and then change its value using the “Set variable” action.
For example, you could create a Number variable to count, incrementing it within a loop:
Initialize Variable: Count to 0
Array: 1, 2, 3, 4, 5
Apply to each item in Array
Set Variable: Count to Count + 1
Show Count
This logic will display the value of the count variable for each item in the given array.
Executing logic controls is an essential skill, especially with respect to the PL-200 Microsoft Power Platform Functional Consultant exam. By understanding how to implement branches, loops, conditions, error handling, and variables, you’ll be able to create more adaptable and efficient Power Automate flows. Through practice and utilization, these controls can bring greater functionality to your Power Platform tools.
Practice Test
True or false: Using ForEach loop will increase the execution time of your Power Automate flow.
- Answer: True.
Explanation: ForEach loop goes through each item one by one, which can extend the execution time especially if there are a large number of inputs.
In Power Automate, what function can be used to throw an error when an unexpected condition occurs in a flow?
- A) Throw
- B) Error
- C) Terminate
- D) Break
Answer: C) Terminate.
Explanation: Terminate function is used to immediately stop the flow and optionally provides a status and an error message.
Variables in Power Automate can be of which types?
- A) String
- B) Boolean
- C) Array
- D) All of the above
Answer: D) All of the above.
Explanation: Variables in Power Automate can be of type String, Boolean, Array, Object, or Number.
A branch is defined by a set of instructions. True or False?
- Answer: True.
Explanation: A branch is a set of instructions that decide which sequence or block of code will be executed, based on conditions.
Depending upon the event, how many actions can you add to the “OnSelect” property of a button in Power Apps?
- A) Only one
- B) Two
- C) Three
- D) Multiple
Answer: D) Multiple
Explanation: Depending upon the event, you can add multiple actions to the “OnSelect” property of a button in Power Apps.
In Power Automate, is there a way to handle errors on a particular action without stopping the whole flow?
- Answer: True.
Explanation: Using ‘Configure run after’, you can handle errors on a particular action without stopping the whole flow.
In Power Automate, which control can be used to run a set of actions for each item in an array?
- A) If
- B) Switch
- C) ForEach
- D) Do While
Answer: C) ForEach.
Explanation: The ForEach control is used to loop through each item in an array and execute actions.
The Do Until loop can be used in Power Automate. True or False?
- Answer: True.
Explanation: The ‘Do Until’ control in Power Automate allows you to repeat specific actions until a specific condition is met.
What is error handling in Power Automate?
- A) Debugging the program
- B) Managing the errors that occur during the execution of the flow
- C) Reporting the errors
- D) Ignoring errors
Answer: B) Managing the errors that occur during the execution of the flow.
Explanation: Error handling in Power Automate refers to managing and mitigating the impact of errors that occur during the execution of a flow, not merely reporting or ignoring them.
Can we assign default values to variables in Power Apps?
- A) Yes
- B) No
Answer: A) Yes.
Explanation: When we initialize a variable, we can assign a default value to it in Power Apps.
What kind of conditions can you create in Power Automate?
- A) Arithmetic conditions
- B) Logic conditions
- C) Both A & B
Answer: C) Both A & B.
Explanation: In Power Automate, you can create both arithmetic and logic conditions.
Errors in Power Automate can be handled using ‘run after’ configuration. True or False?
- Answer: True.
Explanation: ‘Run after’ configuration in Power Automate allows you to manage how the flow handles error and success scenarios.
Power Apps supports exception handling. True or False?
- Answer: True.
Explanation: Power Apps supports exception handling by using ‘Error’ and ‘IsError’ function to check if an error has occurred and act accordingly.
Are the variables initiated in Power Automate reusable?
- A) Yes
- B) No
Answer: A) Yes.
Explanation: Once a variable is initialized in Power Automate, it can be used throughout the flow which makes it reusable.
You can use loops in Power Apps. True or False?
- Answer: True.
Explanation: While Power Apps doesn’t directly support traditional loops like ‘for’ or ‘while’, it does support looping through tables or collections using functions like ‘ForAll’.
Interview Questions
What is the purpose of implementing logic controls in Microsoft Power Platform?
The purpose of implementing logic controls is to provide the ability to control the flow and behavior of an application in response to specific user actions or inputs.
Define the terms “branches” and “loops” in the context of logic controls.
“Branches” are referred to conditions in the application that cause a different sequence of instructions to be executed. “Loops”, on the other hand, allow a sequence of instructions to be executed multiple times until a certain condition is met.
In Microsoft Power Platform, how can you handle errors in your application logic?
Errors in application logic can be handled with the use of try-catch blocks. This allows you to create a block of code that can handle potential exceptions that may occur during the program’s execution.
What is the role of variables in logic controls?
Variables play an important role in logic controls as they hold data, which can be manipulated and used in different parts of an application. They are used to store data during the execution of a program which can be accessed throughout the life cycle of the application.
How do conditions contribute to the implementation of logic controls in Microsoft Power Platform?
Conditions are used to control the flow of an application by causing different sequences of code to be executed depending on whether certain criteria are met.
What role does Power Automate play in error handling in Microsoft Power Platform?
In Power Automate, you can build flows that include error handling steps that capture and deal with errors in the flow. This can be done by using the Error Handling scope in your flow.
How do you implement loops in Power Automate?
Loops can be implemented in Power Automate using the “Apply to each” action. This action performs the same operation for each item in an array.
What is the use of boolean variables in logic controls?
Boolean variables are often used in logic controls to hold a true or false value, making them ideal for conditional statements and control flow logic.
How can you handle exceptions within Power Apps?
You can use the ‘Error’ and ‘IsError’ functions in Power Apps to handle exceptions when they occur. The ‘Error’ function throws an error and the ‘IsError’ function returns a boolean indicating whether an error occurred.
What should you remember about implementing variables in Microsoft Power Platform?
When implementing variables in Microsoft Power Platform, it’s crucial to use the correct data type, initialize the variable before using it, and consider its scope — whether it needs to be accessible throughout the application or just a specific part of it.