How to Count Items in a Power Apps Gallery?

Counting items in a Power Apps gallery is a common task while developing projects. The CountRows function makes it easy to track the number of items in a Power Apps gallery.

In this Power Apps tutorial, I will show you how to count items in a Power Apps gallery and many more:

  1. Power Apps count rows in a gallery after applying filters
  2. Power Apps Group by and find count items in gallery
  3. Count items in a gallery of over 2000 records in Power Apps

How to Count Items in a Power Apps Gallery

To count items in a Power Apps gallery control, refer to the example below:

I have a SharePoint list [ACGH Employees Details] with various columns like:

Column NameData type
Employee NameTitle
Employee GenderChoice [“Male,” “Gender”]
Employee DepartmentChoice [“HR,” “IT,” “Finance,” “Marketing”]
Employee ImageImage
Power Apps Count Items in Gallery

The Power Apps gallery control is connected to the above SharePoint list.

To check the number of items in a Power Apps gallery control, insert a Text label control and set its Text property:

"ACGH Total Employees: "&CountRows(gal_EmployeeDetails.AllItems)

Where,

  1. CountRows = This function helps us to count the number of items in a Power Apps gallery.
  2. gal_EmployeeDetails = Gallery control name
Show number of items in Power Apps gallery

Now, the text label shows the count of employees in a gallery control, as shown below:

Count the rows in a Power Apps gallery

This is how we can count the items in a Power Apps gallery control.

Power Apps Gallery Count Rows With Filter

Now, we will see how to work with Power Apps gallery count rows with filter.

As above, we have checked the number of items [employees] in a gallery.

Next, we will filter the Power Apps gallery by gender, and the text label will display the count of male and female employees, as shown below:

Power Apps count rows in gallery with filter

To achieve it, follow the below steps:

  • Insert a Radio control and set its Items property to:
Choices('ACGH Employee Details'.'Employee Gender')

Where,

  1. ACGH Employee Details = Above SharePoint list name
  2. Employee Gender = SharePoint list choice column name
Power Apps counting rows in a gallery after applying filters
  • Select a Gallery control and set its Items property to:
If(
    rad_Gender.Selected.Value = Blank(),
    Sort(
        'ACGH Employee Details',
        Title,
        SortOrder.Ascending
    ),
    Filter(
        'ACGH Employee Details',
        'Employee Gender'.Value = rad_Gender.Selected.Value
    )
)

Where,

  1. rad_Gender = Radio control name
  2. ACGH Employee Details = Above SharePoint list name
  3. Employee Gender = SharePoint list choice column name
Power Apps Filtered Gallery - Count Rows
  • To check the count of male and female employees in a Power Apps gallery, insert a Text label and set its Text property to:
CountIf(
    gal_ACGHEmployees.AllItems,
    'Employee Gender'.Value = rad_Gender.Selected.Value
) & " " & If(
    rad_Gender.Selected.Value = "Female",
    "Females",
    "Males"
)

Where,

  1. gal_ACGHEmployees = Gallery control name
  2. rad_Gender = Radio control name
How to count rows in Power Apps gallery after applying filters
  • Save, Publish, and Preview the app. When the user selects a value from the radio button; based on it, the text label shows the count of male and female employees in a gallery control, as shown below:
Count rows in a Power Apps gallery after applying filters

This is how we can check the number of items in a Power Apps gallery based on filtering.

Power Apps Group By and Find Count Items in Gallery

Lets check how to group by and find the count items in a Power Apps gallery.

I have a SharePoint list [ACGH Sales Tracking] that has two columns:

  1. Region [Lookup column]
  2. Product Sold [Number column]
Power Apps Group By and Find Count Items in Gallery

Now, I need to verify the number of products sold by Germany, Canada, and Australia, as shown below:

RegionProduct Sold [Count Value]
Germany3 products
Australia1 product
Canada 1 product

Based on the information provided, I need to display sales data grouped by region and present the sales count for each region in my Power Apps gallery.

Group By and Find Count Items in Power Apps Gallery

Follow the below steps to achieve this:

  • On the Power Apps screen, insert a Gallery control -> Set its Items property to:
GroupBy(
    AddColumns(
        'ACGH Sales Tracking',
        "Regions_Name",
        Region.Value
    ),
    "Regions_Name",
    "GroupRegions"
)

Where,

  1. ACGH Sales Tracking = SharePoint list name
  2. Regions_Name = Provide a name for grouping the regions
  3. Region = SharePoint list column name
  4. GroupRegions = Provide a name for a column that contains the record information setup with the GroupBy function.
Power Apps Gallery GROUPBY with counting
  • Inside a Power Apps gallery, insert a Text label -> Set its Text property to:
"Sales Count:" & CountRows(ThisItem.GroupRegions)

Where,

  1. GroupRegions = The column name we provided while grouping the regions.
How to count the rows in Power Apps gallery
  • In the Power Apps gallery, the text label displays the sales data grouped by region, showing the sales count for each region.
How to Group By and Find Count Items in Power Apps Gallery

Power Apps Count Items in a Gallery of over 2000 records

Let us see how to count the number of items in the Power Apps gallery control of over 2000 records.

I have a SharePoint list [ACGH Customer Information] that contains over 2000 items.

Power Apps Count Items in a Gallery of over 2000 records

I connected my SharePoint list to the Power Apps gallery control. Now, to count the number of items in the Power Apps gallery control.

  • Insert a Text label and set its Text property as:
"ACGH Total Customers: " & CountRows(gal_CustomerDetails.AllItems)

Where,

  1. gal_CustomerDetails = Gallery control name
How to count Items in Power Apps gallery of over 2000 records

However, it only displayed 100 records because the gallery initially loads only the first 100 records until the user scrolls to the bottom.

Count Items in a Gallery of over 2000 records in Power Apps

Once the user scrolls to the bottom, the text label will display the number of items in the gallery control, as shown below:

Power Apps Gallery Count Rows Over 2000 Records

This is how to count items in a Gallery of over 2000 records in Power Apps.

In this Power Apps tutorial, I showed you how to count the items in a Power Apps gallery. I covered Power Apps counting rows in a gallery after applying filters.

Lastly, through our tutorial, you have learned:

  1. Power Apps Group By and Find Count Items in Gallery
  2. How to count items in a Power Apps gallery of over 2000 records

Also, you may like: