cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Tamras
Level 10

ForAll update value on each row in collection

I have a collection where it captures the row number displayed in a gallery. If one row is deleted, I want to adjust the row number accordingly.

 

Current formula that applies the row number (in a text box):

If(!IsBlank(ComboBox2.SelectedItems) && !IsBlank(ComboBox1.Selected), Patch(ReviewerCollection, ThisItem, {LineOrder: If(!IsBlank(txtOrder.Text), txtOrder.Text, CountRows(ReviewerCollection))}),If(!IsBlank(ComboBox1.Selected), Patch(ReviewerCollection, ThisItem, {LineOrder:txtOrder.Text}))))

Result in LineOrder column is 1, 2, 3, 4...

 

But when row 2 is deleted, the LineOrder column is 1,3,4...  I want to be able to use ForAll (or UpdateIf) in order to adjust the LineOrder accordingly to 1,2,3. It sounds easy but I can't figure out what function to use.   

1 ACCEPTED SOLUTION

Accepted Solutions
Tamras
Level 10

Re: ForAll update value on each row in collection

Finally figured this out using below formula on OnSelect property of the delete icon.

Remove(ReviewerCollection, ThisItem);
Clear(Counter);
ForAll(ReviewerCollection, Collect(Counter, {RowNum: CountRows(Counter)+1, RowNumOld: Value(LineOrder)})); 
ForAll(Counter, Patch(ReviewerCollection, First(Filter(ReviewerCollection, Value(LineOrder)=RowNumOld)), {LineOrder:RowNum}))

 

View solution in original post

1 REPLY 1
Tamras
Level 10

Re: ForAll update value on each row in collection

Finally figured this out using below formula on OnSelect property of the delete icon.

Remove(ReviewerCollection, ThisItem);
Clear(Counter);
ForAll(ReviewerCollection, Collect(Counter, {RowNum: CountRows(Counter)+1, RowNumOld: Value(LineOrder)})); 
ForAll(Counter, Patch(ReviewerCollection, First(Filter(ReviewerCollection, Value(LineOrder)=RowNumOld)), {LineOrder:RowNum}))

 

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 308 members 5,640 guests
Please welcome our newest community members: