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

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

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