Generate Row Numbers in Power Apps!

Generate Row Numbers in Power Apps

Generate Row Numbers in Power Apps!

Overview:

The blog post provides a step-by-step guide on how to generate row numbers in a Power Apps collection. It covers the process from creating a collection with vehicle data, inserting and customizing a Data Table Control, to adding a row number column in the table.

Power Apps Generate Row Numbers In A Collection

Insert a Button: Add a button control to your Power App screen. Give it a meaningful name like (btncolcars) to adhere to naming conventions.

Write this code on the select property to make the collection

				
					// Create a collection named 'colCars' to store vehicle data 

ClearCollect(colCars, 

    {Year: 2021, Make: "Toyota", Model: "Camry"},     // Vehicle 1 

    {Year: 2022, Make: "Honda", Model: "Civic"},      // Vehicle 2 

    {Year: 2023, Make: "Ford", Model: "Escape"},      // Vehicle 3 

    {Year: 2024, Make: "Chevrolet", Model: "Malibu"}, // Vehicle 4 

    {Year: 2025, Make: "Nissan", Model: "Altima"},    // Vehicle 5 

    {Year: 2026, Make: "Hyundai", Model: "Elantra"},  // Vehicle 6 

    {Year: 2022, Make: "Volkswagen", Model: "Passat"},// Vehicle 7 

    {Year: 2023, Make: "Mazda", Model: "CX-5"},      // Vehicle 8 

    {Year: 2024, Make: "Subaru", Model: "Outback"},   // Vehicle 9 

    {Year: 2025, Make: "Jeep", Model: "Cherokee"},   // Vehicle 10 

    {Year: 2026, Make: "Kia", Model: "Sportage"}     // Vehicle 11 

); 
				
			
image_1

Insert a Data Table Control

In your Power App, insert a “Data Table” control onto your screen. You can do this by selecting the “Data Table” control from the control palette and dragging it onto your screen.

Bind the Data Table Control to the Collection

In the properties pane for the Data Table control, find the “Items” property.

Set the “Items” property to the name of your collection. In this case, it’s

MY Collection name is colCars

Configure the Data Table Control

Customize the Data Table control to display the data as you want in a tabular format. You can define columns, headers, and formatting options

image_2

After The Connect data table with your collection

After connecting this go to the edit field and add your area in my case I have the 3 fields but I want to add to the row number.

image_5

I have only the three fields

image_6

Fields is added and want show data then clicked the button where you create the collection

Data is show in my table

image_8

Write this code in item property of the table to add the row number column

				
					 ForAll( 

        Sequence(CountRows(colCars)), 

        Patch( 

            Last(FirstN(colCars, Value)), 

            {RowNumber: Value} 

        ) 

    ) 
				
			
image_9

Finally we are successful to add the row column in table Go again in edit field

image_10

Go again add field and the field hear we see one new column s created

Here is our column

image_13

That’s it, we’re done!

Conclusion:

Generating row numbers in a Power Apps collection is a straightforward process that adds functionality and organization to data representation. By following the provided steps, users can easily integrate this feature into their applications.

If you want to learn more about the Power Apps, feel free to explore our other informative articles and tutorials.

Have additional inquiries? Our team is here to assist. Please don’t hesitate to reach out!

About The Author