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

Community site session details

Session Id : FRvgNm1FCFgp3WyGPeDKBx
Power Automate - Power Automate Desktop
Unanswered

Dynamic variable name

Like (0) ShareShare
ReportReport
Posted on 9 Feb 2023 08:27:10 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

 

 

  • werkbook Profile Picture
    36 on 12 Feb 2023 at 08:49:24
    Re: Dynamic variable name

    @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/

  • JensDorp Profile Picture
    7 on 09 Feb 2023 at 13:41:48
    Re: Dynamic variable name

    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. 

     

  • momlo Profile Picture
    1,527 Super User 2024 Season 1 on 09 Feb 2023 at 12:42:18
    Re: Dynamic variable name

    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?

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 2

Loading complete