I am unsure how I would achieve this so hoping for some guidance.
I am uploading a local collection to a sharepoint list, that looks something like this:
ForAll(
MyCollection,
If(
MyVariable = false And MyColumn = "New",
Patch(
MySharePointList,
Defaults(MySharePointList),
{
Title: MyTitle,
Reference: Reference
}
)
)
);
I want to append a number to the Reference column sequentially.
So if there are 3 items in the ForAll Loop the outputs would be:
Reference1
Reference2
Reference3
And so on.
What is the best way to achieve this? I would prefer to do this in the upload as this is when we know categorically they final amount of rows that will be uploaded and therefore the sequential numbers that need applying?
Doesn't work for me when updating records via Patch. Strange...
That's a really handy way to add a Counter into a ForAll() loop, I haven't seen that method before. Thanks for sharing!
Hi @digiservice ,
Based on the needs that you mentioned, I think a collection could achieve your needs.
Please consider take a try with the following formula:
Clear(Counter);
ForAll(
MyCollection,
If(
MyVariable = false And MyColumn = "New",
Collect(Counter, 1); // Add formula here
Patch(
MySharePointList,
Defaults(MySharePointList),
{
Title: MyTitle,
Reference: Reference & CountRows(Counter) // Modify formula here
}
)
)
);
please take a try with above solution, check if the issue is solved.
Best regards,
I'm just following along here to see what happens with this because I was building an answer last night - before I fell asleep lol. I've built a solution that works using @timl solution posted by @Carsten_Growth but I'd like to also see what others can produce as well to compare 🙂
@Carsten_Growth
I recognize the code you supplied as a post from the blog of @timl.
Link to blog post: http://powerappsguide.com/blog/post/generating-row-numbers
It looks like @digiservice is conditionally patching information to the datasource based on status of a record. Anyway to combine the code you supplied with what the original poster showed?
---
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."
See this example
Clear(colNumberedInvoices);
ForAll(Invoices,
Collect(colNumberedInvoices,
Last(FirstN(AddColumns(Invoices,
"RowNumber",
CountRows(colNumberedInvoices)+1
),
CountRows(colNumberedInvoices)+1
)
)
)
)
WarrenBelz
85
Most Valuable Professional
MS.Ragavendar
54
Michael E. Gernaey
42
Super User 2025 Season 1