Count Rows in Power Apps Gallery Control

Are you interested in learning how to count all rows/records in the Power Apps gallery control? This Power Apps tutorial will teach all the information about the count rows in Power Apps gallery control.

Here, we will discuss how to get the number of rows in a Power Apps gallery using ‘AllItemsCount’. Then, I will show you how to display the total gallery row count on a Text label.

Additionally, we will learn the Power Apps count rows in the gallery control using the Filter() function and Power Apps gallery count rows over 100 records.

Count Rows in Power Apps Gallery Control

With a simple example, let’s see how to get the total row count in a Power Apps gallery control.

Example:

I have a SharePoint Online list named “Project Tracker“. This list contains the below fields.

Column NameData Type
Project NameDefault single line of text column
DescriptionMultiple lines of text
Project StatusChoice
Start DateDate and time
End DateDate and time

Refer to the below screenshot:

count rows in power apps gallery control

In Power Apps, there is a Gallery control that is connected to my SharePoint list. Now, I want to count all rows in a gallery control and display the row count on a text label as in the screenshot below.

count rows in power apps gallery

To work around this example, follow the steps below. Such as:

1. Open Power Apps with your respective Microsoft credentials -> Create Power Apps Canvas app and connect it to the respective SharePoint Online site like below.

powerapps count rows in gallery

2. Insert a Blank gallery control and set its Items property as:

Items = 'Project Tracker'
powerapps count rows in gallery control

3. Next, Add Text labels inside the gallery to retrieve the records from the SharePoint list, as shown below.

Text = ThisItem.Title

Text = ThisItem.Description

Text = ThisItem.'Project Status'.Value

Text = ThisItem.'Start Date'

Text = ThisItem.'End Date'

Refer to the below image:

Count the Rows in a Power Apps Gallery with AllItemsCount

3. Now, Insert another Text label under the Gallery control and set its Text property to the code below.

Text = $"{gal_Projects.AllItemsCount} Items"

Where,

  • gal_Projects = Power Apps Gallery Name
  • AllItemsCount =This property is used to get all gallery record’s count in Power Apps
Count Rows in Power Apps Gallery with AllItemsCount

4. Save, Publish, and Preview the app. The Power Apps Text input displays total row counts based on the gallery records, as in the screenshot below.

how to count Rows in Power Apps Gallery with AllItemsCount

This is how to get the total row count in the Power Apps gallery control.

Power Apps count Rows in Gallery with Filter

Here, I will show you how to get the Power Apps gallery rows/items count using the Filter() function.

Example:

Here, I will also take the same SharePoint list [Project Tracker] for this example. Now, I want to count all gallery rows based on the SharePoint list choice field [Project Status].

Whenever a user opens a Power Apps Gallery control, it will display only the “Completed “project’s record count, as shown below.

powerapps count rows in gallery with filter

To achieve it, follow the below steps.

1. On the Power Apps Screen -> Select a Text label and set its Text property to the code below.

Text = CountRows(
    Filter(
        gal_Projects.AllItems,
        'Project Status'.Value = "Completed"         //You can also change the choice field value
    )
)

Where,

  • CountRows() = This Power Apps CountRows() function counts the number of records in a table.
  • Filter() = This function is used to find a set of records that match one or more criteria
  • gal_Projects.AllItems = Power Apps Gallery all items/records
  • ‘Project Status’.Value = SharePoint list choice field value
power apps filter count rows in gallery control

2. Save, Publish, and Preview the app. The Text label will filter and display the records/rows count based on the SharePoint list choice value [Completed] as shown below.

how to filter gallery control count rows in power apps

This is how to filter a Power Apps gallery count rows.

Power Apps Gallery Count Rows Over 100 Records

In the last, we will see how to get the Power Apps gallery row count over 100 records with a simple scenario.

Scenario:

  • I have a SharePoint Online list, i.e., [User Subscription Details], which contains 2500 records with different fields as in the screenshot below.
how to show more than 100 records in power apps gallery
  • Now, I will show these records on a Power Apps gallery and get the total row count in the text label. However, the Power Apps gallery will only load the initial 100 records until I scroll down to the bottom.

Refer to the below screenshot:

how to show more than 100 records in power apps gallery control
  • Also, when the user starts scrolling after 100 records, the gallery row count will be higher, but it is not right to count the gallery rows as below.
count SharePoint rows in power apps gallery
  • To resolve this issue, follow the below Text label’s Text property code:
Text = $"{gal_SubscriptionRecords.AllItemsCount}{If(
    First(
        Sort(
            'User Subscription Details',
            ID,
            SortOrder.Descending
        )
    ).ID <> Last(gal_SubscriptionRecords.AllItems).ID,
    "+"
)}  Items"

Where,

  1. gal_SubscriptionRecords = Power Apps Gallery Control
  2. ‘User Subscription Details’= SharePoint Online List
  3. “+” = Use this symbol when the gallery row count is unknown. But once you get to the last row, it will disappear
count SharePoint rows in power apps gallery control
  • Now, when the user scrolls down to the last row, the text label will display the actual row count without the ‘+’ symbol.
how to count SharePoint rows in power apps gallery

This is all about the Power Apps gallery count rows over 100 records.

Conclusion

I hope this Power Apps tutorial taught in detail information about the count rows in Power Apps Gallery control, including:

  • How to get the number of rows in a Power Apps gallery using ‘AllItemsCount’
  • Power Apps count rows in the gallery control using the Filter() function
  • Working with Power Apps gallery count rows over 100 records

You may also like the following tutorials:

>