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

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,989 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
    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

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 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard