Showing results for 
Search instead for 
Did you mean: 
Regular Visitor

All column values cleared when using UpdateIf to update value of 1 column in collection

I am using a gallery that contains a collection of invoice lines (colInvoiceLinesNew). I have a + icon to add a new record after the last visible row, and a trash can icon to delete a selected row. Screenshot below.




Clicking the + icon to add a new record works without issue. A new record appears with the default values and current records retain their values. The OnSelect code is:


Collect(colInvoiceLinesNew,{InvoiceID: "",LineNumber: ThisItem.LineNumber + 1,CostCenter: "TBD (TBD)",Account: "TBD (TBD)",WorkType: "TBD (TBD)",LineAmount:0})


However, when I click one of the trash can icons to delete the relevant row, all of the rows in the gallery below the one deleted reset to the default values instead of retaining what appears on the screen. Any rows above the one deleted retain their values. The OnSelect code is:


Set(LineNumberDel, ThisItem.LineNumber);
UpdateIf(colInvoiceLinesNew,LineNumber>LineNumberDel,{LineNumber: LineNumber-1})


It seems that the UpdateIf code is causing my issue, but I'm not sure how to resolve it. Any help is greatly appreciated.




Community Support
Community Support

Hi @flybrit ,


According to your description, I did the test for you.

Unfortunately, I cannot reproduce your problem.

Your code works in my environment.


Please refer to the steps below:

1\ This is my test collection.



2\ Add a gallery control 


3\ Insert a trash Icon into gallery control and set its onselect property to:

RemoveIf(colInvoiceLinesNew,LineNumber = LineNumberDel);
UpdateIf(colInvoiceLinesNew,LineNumber> LineNumberDel,{LineNumber:LineNumber-1})


4\ The result is as follows:



Please try to change the version of powerapps.



You could also try to use my collection to do the same test to find out whether this phenomenon is caused by other reasons.


Best Regards,
If my post helps, then please consider Accept it as the solution to help others. Thanks.


Regular Visitor

Thank you for your reply @v-xiaochen-msft. I updated the authoring version to 3.21031.41, but that didn't resolve the issue. I will recreate the screen from scratch and see if somehow that solves the issue.

Helpful resources

PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

PA Community Call

Power Apps Community Call

Next call is happening on April 21st at 8a PST.

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!


Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (51,773)