cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NewBee117
Kudo Collector
Kudo Collector

Get the data array out of "Apply to Each"

I initialize the variable ApplytoeachOutput to an array, then set it to the array from the selection in the "Apply to each" loop, all looks fine in the loop. However, when I call the ApplytoeachOutput outside the loop, it has the same amount of items, yet the value is repeating the last row. Any idea what is the proper way to get the selected data out of the "Apply to each" loop?

    

   NewBee117_0-1620401272127.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
zaphod88
Responsive Resident
Responsive Resident

You have to replace your "Set variable" action by "Append to array". If you want to, you can also get rid of the SelectItem action and replace it by the following formula in "Append to array":

{ 
"ID": @item()?['ID'],
"Title": @item()?['Title']
}

 and so on, just insert your own need columns. The "@"-mark means it has to be insertes by expression editor.

View solution in original post

1 REPLY 1
zaphod88
Responsive Resident
Responsive Resident

You have to replace your "Set variable" action by "Append to array". If you want to, you can also get rid of the SelectItem action and replace it by the following formula in "Append to array":

{ 
"ID": @item()?['ID'],
"Title": @item()?['Title']
}

 and so on, just insert your own need columns. The "@"-mark means it has to be insertes by expression editor.

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

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