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.
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.
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?
Solved! Go to Solution.
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.
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.
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 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.