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.
Solved! Go to Solution.
Hi @Collin_Davis :
Could you tell me :
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
@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."
Hi @Collin_Davis :
Could you tell me :
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
I found 1 article which shows to show sequence number without using collection here.
http://powerappslearning.com/serial-number-index-number-in-gallery-control-powerapps/.
I hope it will help you
User | Count |
---|---|
162 | |
96 | |
76 | |
72 | |
59 |
User | Count |
---|---|
213 | |
166 | |
97 | |
95 | |
77 |