0

A dynamic variable name in Power Automate means that the name of the variable is not fixed, but instead, it is determined at runtime based on some criteria or logic. This is useful when you want to create multiple variables with unique names, or when you want to store different values for different iterations of a loop.

In theory, you might try to go about it like this:

To create a dynamic variable name in Power Automate, you can use an expression or a variable that contains a string value as the name of the variable.

Here’s an example of how you can use an expression to create a dynamic variable name:

Add the “Initialize Variable” action block from the “Variables” category in the action library.

In the “Variable name” field, select the expression icon.

Enter an expression that creates the dynamic variable name, such as: concat(“Variable”, variables(‘Counter’))

Set the type and value of the variable as desired.

In this example, the variable name is created using the “concat” function, which concatenates the string “Variable” with the value of another variable named “Counter”.

Does the above work in practice? No, it does not work.

The expression icon is not available in the “Variable name” field in the “Initialize Variable” action block. The name of the variable in Power Automate must be a static string value and cannot be determined dynamically. However, you can still use the value of a dynamic expression in the “Value” field of the “Initialize Variable” action block to store dynamic values.

Alternative to Power Automate Dynamic Variable Name

You can try it by initializing an array at the top level and
using the “Append to array variable” action from inside a For Each action block instead:

Power Automate Dynamic Variable Name
Power Automate Dynamic Variable Name

 

Initialize an array variable at the top level of your flow with the “Initialize variable” action.

Use a loop, such as “For each”, to iterate over some data.

Within the loop, use the “Append to array variable” action to add the current item to the array variable that was initialized at the top level.

For example, if you have a list of names, you can use a loop to create variables for each name and store them in an array:

Initialize an array variable named “listOfCustomers” with the “Initialize Variable” action.

Use a “For Each” loop to iterate over a list of names.

Within the loop, use the “Append to array variable” action to add the current name to the “listOfCustomers”.

Now, you can access each dynamic variable in the “listOfCustomers” by its index in the array.

Have a Question ?

Fill out this short form, one of our Experts will contact you soon.

Call Us Today For Your Free Consultation