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

Announcements

News and Announcements icon
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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 594

#2
Valantis Profile Picture

Valantis 328

#3
David_MA Profile Picture

David_MA 281 Super User 2026 Season 1

Last 30 days Overall leaderboard