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

1 REPLY 1
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

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

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