HI there,
I have a collection which i am going to patch to my CDS but before that i need to increment a number on a each row , if a another column equals something so :
UpdateIf( collection1, ThisRecord.NewExistingComponent = "New Part", { Counter: Counter + 1 } )
So if NewExisitingComponent = NewPart then incremenral Counter by 1. So there maybe 50 rows in a colleciton so therefore the Counter row needs to go from 1 to 50 if the other column = "new part"
I am really struggling with this at the moment.
Using this code you can create a new collection called 'mySolution' that includes a row number
//Row counter collection
ClearCollect(rowCounter,{Value:1});
//Row number code
ClearCollect(mySolution, AddColumns(collection1, "Counter", 0));
ForAll(
collection1,
Patch(mySolution, LookUp(mySolution, RowNumber=0), {Counter: First(rowCounter).Value});
Patch(
rowCounter,
First(rowCounter),
{Value: First(Sort(mySolution,Counter,Descending)).Counter + 1}
);
);
I adapted the solution from the code on my website
https://matthewdevaney.com/powerapps-collections-cookbook/add-a-row-number-column-to-a-collection/
---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."
Seems reasonable and it works great - thanks ! It brings in all the numbers 🙂
What if I wanted it on a query ? So If a column = yes in the gallery and then add the number. if the column contained anything else then ignore ?
any help would be awesome
Stay up tp date on the latest blogs and activities in the community News & Announcements.
Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
User | Count |
---|---|
198 | |
176 | |
62 | |
34 | |
32 |
User | Count |
---|---|
344 | |
273 | |
111 | |
75 | |
59 |