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 Platform Community / Forums / Power Automate / Variable within a vari...
Power Automate
Unanswered

Variable within a variable, for each current item

(0) ShareShare
ReportReport
Posted on by 2

I know I can have CurrentItem['Backup'] and it will go to the column named Backup. but what I am trying to do is:
CurrentItem[%Var%]

This obviously doesn't work, but would there be a way to get it to work?

 

Right now, I have a work around, where I just change the active page and read from that, but I would like to not have to do that.

 

Any ideas? Thanks.

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @Cbowman 

     

    You should try like this 

     

    %CurrentItem[Var]% instead of CurrentItem[%Var%] 🙂

     

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

  • MichaelAnnis Profile Picture
    5,727 Moderator on at

    A bot, or most any coding for that matter, cannot use variables to create variables because all variables must be defined before the play button is pressed. 

    I don’t know why, with the advancement of technology, this limitation still exists, but it does. It is a very practical request especially when you don’t know how many of those variables you will have per run. 

     

    I always suggest two ideas for this, 1 is practical, and 1 is just fun because it breaks all the rules and really is bots building bots. 

    option 1 (practical):  you write to excel column A, the variable you want to build, you write to column B, the variable value you want to retrieve.  In C1 you have an input cell (where the bot writes to excel the variable it wants).  In D1 you have a Vlookup which is the output cell. After writing to C1, the bot reads the variable value from D1, and can write it to the predefined variable for that loop. So, it doesn’t always know it within the bot, but it can always access it later. 

    now the fun one. I’ve only done this once and it was 4 years ago. I built a bot that opened that went to Power Automate Desktop, made a new flow, and was put on a loop to make actions that both create and set environment variables from Col A and B above (in option 1).  It then saves and closes the bot. The bot that you currently running, then runs that flow. All the variables are created as environment variables, and then you can “Get Environment Variable”. 

    At the end of the day, while impressive, it was still a party trick because you have to save the “get environment variable” to an actual variable within your original bot, because the variable names must all exist before you press play. So I ended up using the Excel option as it was much faster and gave me the same result. 

    good luck!

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    The correct way to access object/table/list elements is to pass it as

    • a literal value within square brackets and quotes such as %CurrentItem['Backup']%
    • a variable value within square brackets without quotes and without percentage notation, such as %CurrentItem[Variable]%
    • a literal numeric value within square brackets and without quotes, such as %CurrentItem[1]% (for data tables, lists and data rows - this won't work on custom objects).

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

  • Cbowman Profile Picture
    2 on at

    It's not working. Maybe the setup is wrong.

    I am including pictures. Picture 1 is input, where it goes down the list (A2 with value of a), then returns the appropriate values on at a time in picture 2 for the column labeled a. Once that is done, it goes back to the first page and starts with A3

    Screenshot_20230917-093748.png

    Screenshot_20230917-094017.png

     

  • Nived_Nambiar Profile Picture
    18,138 Super User 2026 Season 1 on at

    Hi @Cbowman 

     

    Can i see how you tried same in the flow ?

     

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 227 Super User 2026 Season 2

#2
David_MA Profile Picture

David_MA 213 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 151

Last 30 days Overall leaderboard