Variables and Test(Power Automate Desktop)

05/17/2023

Japanese version.

Elementary use of variables is introduced (numerical computation, string concatenation, testing).

What is a variable.

It is like a box that temporarily stores numerical, textual, or other data in Power Automate Desktop.

Variables are created in the "Set variable" Action. They are then read and updated in various actions.

Many actions return the result set to the variable.

The results are only stored temporarily and are lost when the flow ends, so if you want to keep them permanently, you must store them in a file or database.

Data type

Variables have different types of data to store.

There are many types of data types, including numeric types for numbers, text types for text, list types for storing multiple data, and many others.

Depending on the data type, the data to be stored may be limited, or the structure may contain more detailed data inside.

Usage Steps

Numeric Calculation

Drag the "Set variable" action from "Variables" onto the workspace.This "Set variable" action is also used to update existing variables.

Set the variable as the "Set variable" window for the variable is displayed.

Specify the name of the variable in "Setting" and the set value or formula to the variable specified in "Variable" in "Value".

There are various rules for variable names, but for now, use
For now, it is safe to start with a single-byte alphabetical character and use only single-byte alphanumeric characters and underscore (_).

In the example below, the variable "num_1" (enclosed in %) is set to 10.

Next, another "Set variable" action is set up to perform the calculation using "num_1".

Setup the "Set Variables" window.

The {x} in this window is used to select an existing variable.

If the value is set to "%2 * (Num1 + 5)%", the variable num_1 will be calculated to "2 x (num_1 + 5)".

Since num_1 is set to 10, the result is 30 and stored in num_1.

(If not enclosed in %, the result is a fixed value; if enclosed in %, the result is a mathematical expression.)

SymbolCalculationFormula Example
+addition%4 + 2%
subtraction%5 - 2%
*multiplication%4 * 3%
/division%10 / 3%
modRemainder of division%10 mod 3%
List of arithmetic operators

String Combining

The "Set variable" action is also used for strings.

In the example below, the variable "str_1" is set to "xyz".

Next, the strings are concatenated.

To do so, use a + sign inside a % sign.
Fixed value strings that are not variables are enclosed in '.

In the example below, the result is "abcxyzABC".

Manipulating Variables

Variables created in the "Variable Settings" section can be manipulated in the "Variables" section.

Rename Variable

Click on "…" (More actions) to the right of the variable.

Click on "Rename".

You will be in a state to change the variable name.

If you change it here, the variable name change will be applied to all actions that use this variable.

Where the variable is used

Click on "…" (More Actions) to the right of the variable.

Click on "Find Usage."

A list of locations where the variable is used will be displayed.
Double-click on a search result to go to the corresponding action.

Mark variables as Sensitive Information

Used for sensitive information such as passwords.

To use, click on "Mark as sensitive" on the right side of the variable.

The information will be treated as sensitive and the contents will not be available for review.

Displaying the contents of variables

When a flow is executed, the contents of variables are displayed.

If the flow is stopped midway, the contents will be those of the point in time when the flow was stopped, When the flow is completed, the contents of the last state are displayed.

A separate window appears when you double-click on a variable.

Arrays and complex objects may require this state to see their contents.

Test

The right side of the flow creation window is the inspector. (A function that displays the contents of variables in the running program, etc.)

By using this, you can efficiently create a flow while checking its behavior in detail.

Test execution methods include step execution and breakpoints.

Step execution

This method checks the contents of variables by moving them one action at a time.

Clicking "▷|" executes one action at a time. ("▷|" executes until the end)

The inspector on the right shows the contents of the variable at that moment. Clicking on "▷|" further advances the flow one action at a time, while clicking on "▷" in the middle of the flow will advance the flow to the end(unless there is an error or breakpoint as described below).

(unless there is an error or a breakpoint as described below).

Breakpoints

If you want to test in detail after moving to the required location,

Breakpoints are efficient when you want to test in detail after moving an action to the necessary point.

Click the left side of the action to display "●" (breakpoint).

Clicking "▷" in this state will pause at that action.

From there, you may move one action at a time with "▷|" or

You may also proceed all at once with "▷".

For those who want to learn Power Automate Desktop effectively


The information on this site is now available in an easy-to-read e-book format.

Or Kindle Unlimited (unlimited reading).

You willl discover how to about basic operations.

By the end of this book, you will be equipped with the knowledge you need to use Power Automate Desktop to streamline your workflow.

Links

Introduction

Variables Actions.