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

Announcements

News and Announcements icon
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:
  • ANB Profile Picture
    7,252 Super User 2026 Season 1 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
    156,526 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
    156,526 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 402 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 296 Most Valuable Professional

Last 30 days Overall leaderboard