cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Wicky1
Regular Visitor

How to get index of item in array in the select action

Hi all,

I created a select action  in *From in put array of object names Value and in *Map I put this expression

 

json(replace(string(outputs('Compose_9')),concat('[',outputs('Compose_6'), ']'),string(item()?[outputs('Compose_6')])))

 

So I know that item() is returns the item that is in the array names Value but I want to get an index of each value in  the array.

 

Is it possible to get index of each value in  the array in the select action.

 

Thank you for the advice 

1 ACCEPTED SOLUTION

Accepted Solutions
v-siky-msft
Community Support
Community Support

Hi @pawelzebrowski ,

 

My idea is to add an index property into Array, which is a number that is incremented from 0. The following steps are for your reference.

1. initialize an integer variable to 0

2. create an Apply to each step to loop through each record within Array

3. add a compose step within apply to each, and put the following expression into Inputs field.

 

addProperty(item(),'index',variables('varNum'))

 

4. add a Set variable steps to make variable increment by 1

 

add(outputs('Compose_3')?['index'],1)

 

5. create a Select steps out of Apply to each loop, reference the output of compose step mentioned in step 3 in From field, then use item()?['index'to get index of array.

Snipaste_2020-12-01_11-05-37.pngSnipaste_2020-12-01_11-15-18.png

 

Hope this helps.

Sik

View solution in original post

2 REPLIES 2
v-siky-msft
Community Support
Community Support

Hi @pawelzebrowski ,

 

My idea is to add an index property into Array, which is a number that is incremented from 0. The following steps are for your reference.

1. initialize an integer variable to 0

2. create an Apply to each step to loop through each record within Array

3. add a compose step within apply to each, and put the following expression into Inputs field.

 

addProperty(item(),'index',variables('varNum'))

 

4. add a Set variable steps to make variable increment by 1

 

add(outputs('Compose_3')?['index'],1)

 

5. create a Select steps out of Apply to each loop, reference the output of compose step mentioned in step 3 in From field, then use item()?['index'to get index of array.

Snipaste_2020-12-01_11-05-37.pngSnipaste_2020-12-01_11-15-18.png

 

Hope this helps.

Sik

wenas
Regular Visitor

It worked for my scenario, thank you! I was able to get and Index according to each item index in excel table! and update my sharepoint list automatically!

 

wenas_1-1660154982521.png

 

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (1,035)