cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Cayshin
Resolver II
Resolver II

How to access/reference a Table cell or List element?

Say I have an Excel file with a variable number of rows, but the same number of columns.

I need to extract the data from the specific columns in each row and set that cell value to a variable.

 

So far this is what I have to select the used range, but I'm stuck on the For Each loop.

Cayshin_0-1607609902529.png

 

I've used Message Boxes to confirm the For Each loop is iterating through each row, but how do I access a specific element of that row?

For instance, in my For Each loops, I want set 4 different variables, one to each value from each column of that row. I can't figure out how to access the specific column's value.
In the Flow variables, I see I can expand CurrentItem to select some elements, but not how to reference a column.

Cayshin_1-1607610409602.png

 

So another idea I had was to Split the row to generate a List, but then I ran into the same problem of how to access an element in that list. Like if I was using Python, the List's Index[0] would end up as the first column, Index[1] would be the second column...

 

Any suggestions on how to accomplish this?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Dszum
Regular Visitor

Hey Cayshin,

 

CurrentItem variable from the "For each" action is of type Datarow, so you should be able to access a column's value by using the index position.

 

For example %CurrentItem[0]%' will give you a value of the first column. 

 

Dszum_0-1608137390143.png

 

View solution in original post

5 REPLIES 5
Cayshin
Resolver II
Resolver II

So I just solved my own question, but I don't think it's very pretty or efficient. If anyone has a better idea, please post below.

 

I used a Count variable and a Switch condition to set the correct variables.

Cayshin_0-1607611245170.png

Cayshin_1-1607611288560.png

 

 

Dszum
Regular Visitor

Hey Cayshin,

 

CurrentItem variable from the "For each" action is of type Datarow, so you should be able to access a column's value by using the index position.

 

For example %CurrentItem[0]%' will give you a value of the first column. 

 

Dszum_0-1608137390143.png

 

Thanks @Dszum, that's exactly what I was hoping for!

AdminSCMENAPP
New Member

@Dszum Is there any possible way to increment index number based on loop count? 

@AdminSCMENAPP  Yes %ArrayName[LoopCounterVarName]%

For example %CurrentItem[SomeCounter]% (you can declared %SomeCounter% and increase it in your For Each).

 

Everything you write between percent symbol % % that matches a declared variable name on your flow, the compiler will refer to it.

 

Have a nice day.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (1,490)