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 / Numbered Items in a Ga...
Power Apps
Answered

Numbered Items in a Gallery

(1) ShareShare
ReportReport
Posted on by 11

Collin_Davis_0-1597264789301.png

As shown above, I have a gallery with a couple of entries in it. I am wanting be number each entry based off of which row it is in. If it is the first entry (in the first row), then I would like to have the number 1 displayed in a text box.

In the above screenshot, I had "This Item . Description" (with no spaces) as the main label, but wanted the number to be next to that. I created a second text box to try to test my desired action. I ended up trying an html text editor because it would allow the same look as a normal text box (unlike the rich text editor). With this, I tried the following code:

Concatenate("<ol><li>", This Item . Description)

This returned the correct look that I was wanting, but when I added a second entry to the gallery, the system did not auto-increment the number. Is there any way to accomplish this task?

Thank you in advance.

Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,991 Moderator on at

    @Collin_Davis 
    You can use the code in this example to add a row number to a datasource or collection.  Then you could add the row number in a label within the gallery.

     

    Link to Add A Row Number:
    https://matthewdevaney.com/powerapps-collections-cookbook/add-a-row-number-column-to-a-collection/

     

     

    If you'd like some further help, please supply any information I would need to recreate your problem.  I'd love to figure this out with you!

     

    ---
    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." 

  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @Collin_Davis :

    Could you tell me :

    • What is the gallery's items property?
    • How did you add the second entry?
    • What is your data source's primary key?(Unique identifier)I assume it is "ID".

    The easiest way is to add an auto-incrementing field to your data source.

    If you are unwilling to modify your data source, the only way is to use the data in the original data source to create a new collection .I've made a test for your reference:

    1\Set the screen's OnVisible property to:

     

    Clear(colNumberedInvoices); /*colNumberedInvoices is a custom collection*/
    ForAll(yourdatasource, 
     Collect(colNumberedInvoices,
     Last(FirstN(AddColumns(yourdatasource,
     "RowNumber",
     CountRows(colNumberedInvoices)+1
     ), 
     CountRows(colNumberedInvoices)+1
     )
     ) 
     )
    )

     

    2\Add a label control into the gallery and set it's Text property to:

     

    LookUp(colNumberedInvoicesm,ID=ThisItem.ID).RowNumber /*I assume ID is the unique identifier of your data source*/

     

    Because the Row Number is stored in colNumberedInvoicesm, we need to use lookup to find the corresponding record in colNumberedInvoicesm to get the value of rownumber.

    The reason why I don't directly use colNumberedInvoicesm as the data source of the gallery is because the data structure of colNumberedInvoicesm and your data source is different, which may cause some errors.

    Best Regards,

    Bof

     

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 528

#2
WarrenBelz Profile Picture

WarrenBelz 426 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 306

Last 30 days Overall leaderboard