cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Kudo Kingpin
Kudo Kingpin

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
Highlighted
Kudo Kingpin
Kudo Kingpin

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
Highlighted
Kudo Kingpin
Kudo Kingpin

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
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,446)