web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Adding a ID column to ...
Power Apps
Answered

Adding a ID column to a Collection

(0) ShareShare
ReportReport
Posted on by 101

I would like to add a column with an ID number to a collection.  I've tried the formula below, but it is not working for me.

 

ClearCollect(
 colSolution,
 ForAll(
 Sequence(CountRows(colVehicles)),
 Patch(
 Last(FirstN(colVehicles, Value)),
 {RowNumber: Value}
 )
 )
)

 

Can anyone advice me on what I should do?

Categories:
I have the same question (0)
  • ANB Profile Picture
    7,223 Super User 2025 Season 2 on at

    Hi @MicroMarc365 , Can you try this:

     

    ClearCollect(
     colSolution,
     ForAll(
     Sequence(CountRows(colVehicles)) As var,
     Patch(
     Last(FirstN(colVehicles, var.Value)),
     {RowNumber: var.Value}
     )
     )
    )

     

    EDITED:

     

    If the above code didnt work then check below posts:

    https://powerusers.microsoft.com/t5/Building-Power-Apps/Auto-Increment-ID-on-Collect/td-p/1867260

    https://powerusers.microsoft.com/t5/Building-Power-Apps/Adding-incremental-column-to-collection/td-p/314504

     

    -----------------------------------------------------------------------------------------------------------------------------

    I hope this helps.

    Please click Accept as solution ✅ if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs up.👍

    Thanks,
    ANB


  • Verified answer
    WarrenBelz Profile Picture
    153,079 Most Valuable Professional on at

    @MicroMarc365 ,

    Assuming colVehicles exists with the data you want, that should work (a small improvement below) - what result are you getting ?

    ClearCollect(
     colSolution,
     ForAll(
     Sequence(CountRows(colVehicles)),
     Patch(
     Index(
     colVehicles, 
     Value
     ),
     {RowNumber: Value}
     )
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • MicroMarc365 Profile Picture
    101 on at

    Do I need to replace "Value"? 

  • Verified answer
    WarrenBelz Profile Picture
    153,079 Most Valuable Professional on at

    @MicroMarc365 ,

    I have fixed the post - try now. You should have a new column called RowNo

  • MicroMarc365 Profile Picture
    101 on at

    That worked!  Thank you so much!  

    How can I add a number to each row that is created? 

    Example:

    ID

    Animal

    1

    Dog

    2

    Cat

    3

    Fish

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard