web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Automate
Unanswered

Dynamic variable name

(0) ShareShare
ReportReport
Posted on by 7

I want to create a loop where the variable name is dynamic.

JensDorp_3-1675931080639.png

JensDorp_2-1675931045559.png

So, in this case I want the variable "test" to increase with the count. So, the variable is called "test0", "test1", "test2" as the loop goes, so it does not overwrite the existing variable.

 

But I constantly gets a syntax error when I try to use different inputs. Is there a way to do this? 

 

Kind regards

 

 

I have the same question (0)
  • momlo Profile Picture
    1,527 Super User 2024 Season 1 on at

    This is not possible to declare variables dynamically.

    You could use data table and store key value pairs for example:

     

    PseudoVariablename : Value

    var1 : value1

    var2 : value 2

    var3 : value 3

     

    What do you want to achieve with this approach?

  • JensDorp Profile Picture
    7 on at

    I want to build general subflows I can use across different solutions. I am aware that I can create data tables and store the values there, but in some cases that is problematic. 
    Example:

    JensDorp_1-1675950013710.png


    Here I must attach to multiple Excel-instances and I want them to be saved under different variables so I can call them later on. But the loop in this case overwrites the previous instance and I can’t save the instance in a datable as is it not understood as an excel-instance and the call therefore will fail.

     

    But as i understand it there is no simple workaround this. 

     

  • werkbook Profile Picture
    36 on at

    @JensDorp 

     

    Have you tried creating a list using the action Create new list? Then use the action Add item to list to store the data into the list.

    Create new list.jpg

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    To retrieve the items stored in the list, use the notation %VariableName[ItemNumber]%. In the example above, it will be %List[0]%, %List[1]% and %List[3]% for the first 3 items in the list respectively. Note that the ItemNumber or index starts from 0. Going back to your question, %List[0]%, %List[1]% and %List[3]% will be the closest thing you can get to dynamic variables. Hope this helps.

     

    To learn more, visit https://werkbook.co/

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard