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 / Struggling with embedd...
Power Automate
Answered

Struggling with embedded variable references to data table elements ...

(0) ShareShare
ReportReport
Posted on by 4

I've created a flow that builds a table (8 columns x 20 rows) from web data. I'm now trying to build a loop that looks at the first cell of each row to evaluate the contents.

 

However, I cannot seem to find a structured reference for the loop that doesn't generate a syntax error.

 

If I try, "For each %CurrentItem% in %DataFromWebPage%" I get 20 iterations, which is what I want. However, within the loop, I don't seem to be able to use the %CurrentItem% variable as part of a structured reference. %DataFromWebPage[0][0]% gives me the first row, first column. But, I can't find a way to embed a reference to %CurrentItem% to bring my looping construct into the loop. What's the right syntax for embedding a variable reference within a variable reference? I want something like %DataFromWebPage[%CurrentItem%][0] and I get why that doesn't work, but I can't find an escape character that allows me to do the embedded declaration ... any advice?

 

Sorry if this is a dumb question ...

I have the same question (0)
  • Verified answer
    John_Mavridis Profile Picture
    Microsoft Employee on at

    Hello there and thank you for your question!

    Iterating through a datatable variable with a 'For each' loop - as you have already done so - is indeed a correct first step; this provides you with a datarow variable in each iteration, stored within the %CurrentItem% variable.

    Within the iteration, you can reference the individual elements of the datarow by using indices, via the notation %CurrentItem[0]% - this would get you for instance the first cell of the respective row, as indices are zero-based in PAD variables. Similarly, you could use %CurrentItem[1]%, %CurrentItem[2]% and so on.

    For your reference, another approach you could use is a nested 'Loop':

    Loop from 0 to 19, incrementing by 1 and storing in %RowIndex%
       Loop from 0 to 7, incrementing by 1 and storing in %ColumnIndex%
           %CurrentVar%= %DataFromWebPage[RowIndex][ColumnIndex]%
       End

    End

     

    Of course, this approach would iterate through all the elements of all the rows one by one, so maybe it's not optimal for what you are trying to achieve. But it should give you an idea of the proper use of indices for datatable variables as well.

    Last but not least, when you are referencing columns, in case you have column headers available in your variable, you can also use the notation %CurrentItem['<ColumnHeader>']% or %DataFromWebPage[RowIndex]['<ColumnHeader>']%. This is handy when you want to easily remember which column you are referring to.

    Please let us know if the above explain things for you. Thank you!

  • gmmurray Profile Picture
    4 on at

    Brilliant! I didn't realize that the %CurrentItem% was, itself, both the iterative construct and a data element. Thank you, kind sir.

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 June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 227

#2
David_MA Profile Picture

David_MA 204 Super User 2026 Season 1

#3
Valantis Profile Picture

Valantis 177

Last 30 days Overall leaderboard