PowerApps Count Function with Examples

In this PowerApps tutorial, We will see what is count function in PowerApps, What is its syntax, and how the PowerApps count function works in a PowerApps app.

Also by taking some simple scenarios, We will cover these below topics that are related to the PowerApps Count Function as:

  • PowerApps countA function
  • PowerApps CountA function Syntax
  • PowerApps CountA function Example
  • PowerApps count items in gallery
  • PowerApps count items in collection
  • PowerApps count items in sharepoint list
  • PowerApps count items in listbox
  • PowerApps count characters
  • PowerApps count filter
  • PowerApps count distinct or PowerApps count duplicates
  • PowerApps count attachments
  • PowerApps count array
  • PowerApps count button clicks
  • PowerApps count days between dates
  • PowerApps group by count rows
  • PowerApps count combobox items
  • PowerApps count checkbox
  • PowerApps count choices
  • PowerApps chart count
  • PowerApps count dropdown items
  • PowerApps countdown timer
  • PowerApps count days in month

PowerApps Count function

PowerApps Count function helps to count the total number of items or records that contain a number in a single column table.

PowerApps Count function Syntax

Below represents the syntax of PowerApps Count Function:

Count( SingleColumnTable )

Where,

SingleColumnTable = This option is required that specifies the Column of records to count.

PowerApps CountA function

  • PowerApps CountA function helps to count all the records that are not blank in a single column table.
  • This CountA function is having an empty text (” “) in the count.

PowerApps CountA function Syntax

Below represents the syntax of PowerApps CountA Function:

CountA( SingleColumnTable )

Where,

SingleColumnTable = This option is required that specifies the Column of records to count.

PowerApps CountA function Example

PowerApps CountA function helps to count the total number of non-empty cells that are present in a table, SharePoint list, or a PowerApps gallery control.

  • The below screenshot represents the SharePoint list named Products. This list has some columns. Among them, it has a Quantity column (Number Datatype).
  • Here I would like to count the total number of Quantity values that is non-empty.
PowerApps CountA function Example
PowerApps Count Function
  • On the PowerApps screen, Insert a label control and apply this below formula on its Text property as:
Text = "Total number of non empty cells: " & CountA(Products.Quantity)

Where,

  1. Products = SharePoint list name
  2. Quantity = SharePoint Column name. It is required that helps to count the total number of non-empty cells that present in the SharePoint list.
PowerApps CountA function
PowerApps CountA function
  • Save and Preview the app. You can see the total number of nonempty cells in the label control as shown in the above screenshot.

PowerApps count items in gallery

Here we will see how to count all items or all records from a PowerApps Gallery control. Refer to the below example.

Items = [ "Male", "Female", "Transgender" ]
PowerApps count items in gallery
PowerApps count items in gallery
  • Next, I want to filter the gallery and need to count the radio button values using the PowerApps Count function.
  1. Count the total Items in the Gallery control:

To display the total items in the gallery control, I have taken a label control and applied this below formula on its Text property as:

Text = CountRows(Gallery1.AllItems)

Where,

Gallery1 = Gallery control name

PowerApps count items in gallery control
How to count items in gallery in PowerApps

As in the gallery, there are total four number of records, thats why the label is showing the output as 4.

2. Count the total number of Radio button value where is only Male:

Suppose you want to count the total number of only Male value, then apply this below formula on Label’s Text property as:

Text = CountRows(
    Filter(
        Gallery1.AllItems,
        Radio1.Selected.Value = "Male"
    )
)

Where,

Radio1 = Radio button input name

count items in PowerApps gallery control
count items in PowerApps gallery control

As in the gallery, there are total two number of Male value, so the output is showing the value as 2 in the label control.

3. Count the total number of Radio button value where is only Female:

Similarly, if you want to count the total number of only Female value, then apply this below formula on Label’s Text property as:

Text = CountRows(
    Filter(
        Gallery1.AllItems,
        Radio1.Selected.Value = "Female"
    )
)

Where,

Radio1 = Radio button input name

PowerApps count item in gallery
count items in PowerApps gallery control example

As in the gallery, there are total one number of Female value, so the output is showing the value as 1 in the label control.

4. Count the total number of Radio button value where is only Transgender:

If you want to count the total number of only Transgender value, then apply this below formula on Label’s Text property as:

Text = CountRows(
    Filter(
        Gallery1.AllItems,
        Radio1.Selected.Value = "Transgender"
    )
)

Refer to the below screenshot.

PowerApps count rows in gallery
Count total number of Radio button value in PowerApps

As in the gallery, there are total two number of Transgender value, so the output is showing the value as 2 in the label control.

PowerApps count items in collection

Do you think that can you count the total number of records that are present in a PowerApps Collection? Coming to the answer to this thought is, Yes, you can count the total number of items in the PowerApps Collection.

  • The below screenshot represents a PowerApps Collection where the items are retrieved from the SharePoint list. You can see there is a total three number of items in the PowerApps Collection (CountColection).
  • I want to display the number of items (from the collection) in a PowerApps Label control.
PowerApps count items in collection
PowerApps count items in collection
  • Select the Label control and apply this below formula on its Text property as:
Text = CountRows(CountCollection)

Where,

CountCollection = PowerApps Collection name

PowerApps count items in collections
PowerApps count items in collection example
  • As there is a total three number of items in the specified PowerApps Collection, so the label control is showing 3 as the above screenshot.

PowerApps count items in sharepoint list

In this scenario we will see how to work with the SharePoint list using PowerApps Count function.

Exampe -1:

  • There are two SharePoint lists named as:
  1. Project Details
  2. Client Project Details
  • Both SharePoint lists are having some different columns with different data types. Although both lists are having the same column named Project Status with a choice column data type.
  • This column is having the below status as:
    • Submitted
    • Approved
    • Rejected
    • Pending
  • The below screenshot represents the Project Details list with the Project Status Column.
PowerApps count items in sharepoint list
PowerApps count items in sharepoint list
  • Similarly, the below screenshot represents the Client Project Details list having the Project Status Column.
PowerApps count items in a sharepoint list
PowerApps count items in sharepoint list example
  • Now I want to count the total number of records with a particular status (suppose Approved) on both lists.
  • To do so, set the below formula on the screen’s OnVisible property as:
OnVisible = ClearCollect(
    List1Collection,
    'Project Details'
);
ClearCollect(
    List2Collection,
    'Client Project Details'
)

Where,

  1. List1Collection = PowerApps Collection name for the first list
  2. List2Collection = PowerApps Collection name for the second list
  3. Project Details‘, ‘Client Project Details‘ = SharePoint list name
PowerApps count items sharepoint list
How to count items in sharepoint list in PowerApps
  • Next, Insert a Label control and apply this below formula on its Text property as:
Text = CountRows(
    Filter(
        List1Collection,
        'Project Status'.Value = "Approved"
    )
) + CountRows(
    Filter(
        List2Collection,
        'Project Status'.Value = "Approved"
    )
)

Where,

‘Project Status’.Value = This is the choice column from both Sharepoint lists. You need to specify the value as well. Here I need to count only the Approved value, so I have specified it as Approved in the formula.

PowerApps count item in sharepoint list
PowerApps count item in sharepoint list
  • Now Save and Publish the app. Again open the app. You can see the total number of approved values (from both the SharePoint lists) in the Label control as in the above screenshot.

Example – 2:

  • The below screenshot represents a SharePoint list named SharePoint Project Expenses. This list has a Choice column named Project Location.
  • This choice column is having some location names like Bangalore, Mumbai, Chennai, Pune, etc.
PowerApps count items in sharepoint lists
count items in sharepoint list in PowerApps
  • Here what I want to do is, I need to count the number of rows hosted in the SharePoint list based on a selected item from a dropdown list.
  • For example, When the user selects Bangalore or Mumbai, then a function to count all the rows in Sharepoint List which have Bangalore or Mumbai based on the selected items.
  • On the PowerApps screen, I have a Dropdown control that is having all the values from the SharePoint Choice column (Project Location).
  • Select the Dropdown input control and set its Items property as:
Items = Choices('SharePoint Project Expenses'.'Project Location')
PowerApps count items in the sharepoint lists
PowerApps count items in sharepoint list
  • Next, Insert a Label control and apply this below formula on its Text property as:
Text = CountRows(
    Filter(
        'SharePoint Project Expenses',
        'Project Location'.Value = Dropdown1.Selected.Value
    )
)

Where,

Dropdown1 = Dropdown input control name

PowerApps count item sharepoint lists
How to count items in PowerApps in sharepoint list
  • Next, Save and Preview the app. Select a value from the dropdown control, then the label control will display the number of items based upon the selected value as shown in the above screenshot.

SharePoint Choice column with Multiple selections:

  • If you already enabled the “Allow multiple selections” option for the Choice type column, then you need to follow this below formula (On Label’s Text property) as:
Text = CountRows(
           Filter('SPList', Dropdown1.Selected.Value in Concat(FilteredColumn, Value & ";"))
)

Where,

  1. ‘SPList’ = You need to specify your SharePoint List Name
  2. FilteredColumn = Specify the single line of text column
  3. Dropdown1 = Dropdown input control name

With SharePoint Single line Text column:

  • If you use the Single text column to store the Dropdown selected option, then follow this below formula on Label’s Text property as:
Text = CountRows(
                   Filter('SPList', FilteredColumn = Dropdown1.Selected.Value)
)

Where,

  1. ‘SPList’ = You need to specify your SharePoint List Name
  2. FilteredColumn = Specify the single line of text column

With ComboBox control:

  • If you want to select multiple options within your Dropdown box (instead of the Dropdown box control, it will a ComboBox control), then apply this below formula on Label’s Text property as:
Text = CountRows(
           Filter('SPList', Concat(ComboBox1.SelectedItems, Value & ";") in Concat(FilteredColumn, Value & ";"))
)

Where,

ComboBox1 = ComboBox control name

PowerApps count items in listbox

Suppose there is a List box input control on your PowerApps Screen. And you want to count the records that you have selected in the list box. Follow the below scenario.

  • In the below PowerApps List box, it has these many below items on its Items property as:
Items = ["APPLE", "ORANGE", "GRAPES", "MANGO"]
  • Now what I want to do is, it will count the number of records that are selected by the user in the List box.
PowerApps count items in listbox
PowerApps count items in listbox
  • You can add a Label input control and display the count value. Apply this below formula on its Text property as:
Text = CountRows(ListBox1.SelectedItems)

Where,

ListBox1 = you need to specify the List box input control name

PowerApps count items in the listbox
PowerApps count items in listbox example
  • Save and Preview (F5) the app. Select item(s) in the list box control. then you can see the count of selected items in the label control as in the below screenshot.
PowerApps count item in listbox
How to count items in listbox in PowerApps

PowerApps count characters

This topic will show how to return the total number of a given character from a string using the PowerApps Count Function.

Example – 1:

In this example, I want to find the number of ‘p‘ in ‘powerapps‘ (string). For this, Insert a Label control and apply this below formula on its Text property as:

Text = CountRows(MatchAll("powerapps", "p"))

Where,

  • powerapps = you need to specify the string
  • p = specify the letter that you count in the provided string
PowerApps count characters
PowerApps count characters

Alternatively, you can apply this below formula on Label’s Text property as:

Text = CountRows(MatchAll("powerapps", "p", MatchOptions.Contains))
PowerApps count character
PowerApps count characters examples

As in the above-specified string (powerapps), there is a total of three numbers of “p”, thats why the label is showing as 3.

Example – 2:

In the other scenario, I want to get the total number of “.” from the “www.spguides.com” string. Apply this below formula on Label’s Text property as:

Text = CountRows(MatchAll("www.spguides.com", "\."))

Where,

www.spguides.com” = specified the string where I need to cunt the total number of “.” value.

count characters in PowerApps
powerapps count characters in string

Alternatively, you can apply this below formula on Label’s Text property as:

Text = CountRows(MatchAll("www.spguides.com", "\.", MatchOptions.Contains))
count character in PowerApps
powerapps count characters in string example

As in the above-specified string (www.spguides.com), there is a total of two numbers of “.”, thats why the label is showing as 2.

PowerApps count filter

  • There is a SharePoint list named Department Details. It has several columns. Among them, there is one column named Department (it is a title column, I renamed it).
  • Now I want to count the total number of department that has the value IT.
  • In the below screenshot, you can see all the SharePoint list records on the PowerApps gallery control.
  • To count the number of IT in the SharePoint list, add the label and apply this below formula on Text property as:
Text = CountRows(Filter('Department Details', Title="IT"))

Where,

  1. ‘Department Details’ = SharePoint list name
  2. Title = SharePoint column name (Department)
PowerApps count filter
PowerApps count filter

As there is a total of two numbers of IT value, that’s why it is showing 2 in the label control as shown in the above screenshot.

PowerApps count distinct or PowerApps count duplicates

In this example, We will see how to count the total number of distinct or unique items in PowerApps.

  • There is a gallery control on the PowerApps screen where the items are retrieved from a SharePoint list (Products).
  • In the gallery control, you can see, there are some repeated items that are present two or three times in the gallery control.
  • Here I want to count the total number of unique items from the gallery control. To do so, Insert a Label control and apply this below formula on its Text property as:
Text = "Total Number of Distinct items: " & CountRows(Distinct(Gallery9.AllItems,Title))

Where,

  1. “Total Number of Distinct items: “ = This is the text that I want to display in the label control
  2. Distinct = This is the PowerApps function that helps to find out the unique items
  3. Gallery9 = Gallery control name
  4. Title = SharePoint column name. It is necessary to specify which column you want to count the distinct value

Refer to the below screenshot.

PowerApps count distinct
PowerApps count distinct

Save and Publish the app. You can see the total number of distinct items in the existing label control as like the above screenshot.

PowerApps count attachments

Here we will see how to work with the PowerApps Attachments using the Count function. We will see how to count attachments in PowerApps attachment control.

In this topic, I will take two different scenarios to understand better that how to work with PowerApps count attachments.

Example -1:

  • In the below screenshot, I have a SharePoint list named SharePoint Project Expenses. This list has some different types of columns with the Attachments column.
  • Also, it has some records. Among all the records, some of the records having some attachments as shown below.
PowerApps count attachments
PowerApps count attachments
  • On the PowerApps screen, I have a gallery control that is having all the Project name (column name from the SharePoint list).
  • Now what I want to do is, I would like to have an icon (Document) to show the pictures of Attachments, if there’s an attachment, then the icon will be visible to the user otherwise it will be invisible.
PowerApps count attachment
PowerApps count attachments example
  • To do so, Select the first section from the gallery control and add the document icon (Insert -> Icons -> Document) as below.
  • Select the Document icon and set this below formula on its Visible property as:
Visible = !IsEmpty(ThisItem.Attachments)

Where,

Attachments = Attchment column from the SharePoint list

count attachments in PowerApps
count attachments in PowerApps
  • Now Save and Preview (F5) the app. You can see the icon will visible which record is having the attachment otherwise it will invisible.

Example -2:

  • Normally what we do is, We are taking a label control that will help you to display the number of attachments on each record.
  • Suppose instead of counting each record attachment, you want to calculate the total number of attachments from the gallery, then you can apply this below formula on Label’s Text property as:
Text = Sum(
    Gallery3.AllItems,
    'Has attachments'
)

Where,

  1. Gallery3 = Gallery control name
  2. Has attachments‘ = Attachment column name (from the existing SharePoint list)
count attachment in PowerApps
How to count attachments in PowerApps

As in the above gallery control, there is a total three number of attachments, that’s why the label is showing 3 as in the above screen.

PowerApps count array

  • Suppose there is a number of emails of some particular users. And you want to count the number of user emails on the PowerApps screen (by using the PowerApps Count function).
  • Insert a Label control and apply this below formula on its Text property as:
Text = CountRows(
    Split(
 "Bijay@tsinfotechnologies.com;Bhawana@tsinfotechnologies.com;Preeti@tsinfotechnologies.com;Nancy@tsinfotechnologies.com",
        ";"
    )
)

Where,

  1. Bijay@tsinfotechnologies.com;Bhawana@tsinfotechnologies.com and so on = You need to specify the number of user emails that you need to count.
  2. Split = This is the PowerApps function that helps you to divide the user email with a delimiter “;”
PowerApps count array
PowerApps count array

Once you will save and publish your app, you can see the result inside the label control as shown in the above screenshot.

PowerApps count button clicks

In this example, We will see how to count the total number of clicks using the Powerapps button input.

  • I have a SharePoint list named ClickCounts. This list has three different columns like Title, WebURL (Hyperlink data type), and TotalClicks as shown below.
  • Also, it has these many below Web URLs.
PowerApps count button clicks
PowerApps count button clicks
  • On the PowerApps screen, I have a gallery control that is having the URLs (from SharePoint ist data source).
  • Each item in the gallery is having one button input named Click. This button helps to count the number of times a “URL” in a gallery item is clicked. That means it will count total how many times the button is clicked by the user.
  • To do this, select the Button input (Click) and apply this below formula on its OnSelect property as:
OnSelect = Set(
    currentRecord,
    LookUp(
        ClickCounts,
        URL = ThisItem.URL
    )
);
If(
    IsBlank(currentRecord),
    Patch(
        ClickCounts,
        Defaults(ClickCounts),
        {
            URL: ThisItem.URL,
            TotalClicks: 1
        }
    ),
    Patch(
        ClickCounts,
        currentRecord,
        {TotalClicks: currentRecord.TotalClicks + 1}
    )
)

Where,

  1. currentRecord = Variable name
  2. ClickCounts = SharePoint List name
  3. URL = SharePoint column (Hyperink)
  4. TotalClicks = SharePoint column name
PowerApps count button click
PowerApps count button clicks example
  • Now to view the total number of button clicks, you can insert a PowerApps Data table and set its Items property as:
Items = Gallery4.AllItems

Where,

Gallery4 = Gallery control name

  • Save and preview the app. Click one web URL from the gallery control. Then the result will display in the data table like the below screenshot.
PowerApps count on button click
PowerApps count on button click
  • Similarly, click some web URLs as many times as you want, then you can see the result in the data table that how many times you have clicked the specific button.
PowerApps count on button clicks
How to count on a button click in PowerApps

PowerApps count days between dates

Let us assume there are two different dates i.e. (from date) to (to date) in a PowerApps app. And you need to count how many days in between the two dates. Then follow these below things.

  • The below screenshot represents two Date picker control. One Date picker is having the Start Date and another is having the End Date.
  • Here I need to count the total number of days between these two dates. The count will display in a label control.
PowerApps count days between dates
PowerApps count days between dates
  • Select the Label control and set this below formula on its Text property as:
Text = DateDiff(DatePicker1.SelectedDate, DatePicker2.SelectedDate,Days)

Where,

  1. DatePicker1 = Date picker control name of the start date
  2. DatePicker2 = Date picker control name of the end date
  3. Days = This will help you to count the number of days between two dates

Not only you can use Days, but also you can use different units like Years, Hours, Minutes, Quarters, Seconds etc.

PowerApps count days between date
PowerApps count days between dates
  • To avoid negative numbers if the start date is after the end date, then alternatively, you can use this below formula on Label’s Text property as:
Text = If(DateDiff(DatePicker1.SelectedDate, DatePicker2.SelectedDate,Days)<0, 
    DateDiff(DatePicker1.SelectedDate, DatePicker2.SelectedDate,Days)*-1,
    DateDiff(DatePicker1.SelectedDate, DatePicker2.SelectedDate,Days))

Refer to the below screenshot.

PowerApps count days between two dates
PowerApps count days between dates

PowerApps group by count rows

In this scenario, We will see how to work with the PowerApps group by count rows. Also, We will see how to count records with multiple instances.

  • There is a PowerApps Collection named GadgetCollection. This collection has one column named GadgetName.
  • It has some records like Laptop, Mobile, Tablet, etc. This is having some multiple records with the same name i.e. Laptop 3 times, Mobile 2 times, and Tablet 1 time.
  • Now I would like to count the total number of gadgets that should be like the below table as:
Gadget NameCount
Laptop3
Mobile2
Tablet1
  • You can see the PowerApps collection (GadgetCollection) in the below screenshot.
PowerApps group by count rows
PowerApps group by count rows
  • Now to count the records with multiple instances, Insert a Data table and apply this below formula on its Items property as:
Items = AddColumns(
    GroupBy(
        GadgetCollection,
        "GadgetName",
        "ByName"
    ),
    "Count",
    CountRows(ThisRecord.ByName)
)

Where,

  1. GadgetCollection = PowerApps Collection name
  2. GadgetName = Column name from the specific collection
  3. Count = Specify the column name that will have the total number of count of each gadget
  • Once you will save and preview the app, you can see the total count of multiple instances in the data table as shown in the below screenshot.
PowerApps groupby count rows
PowerApps group by count rows

PowerApps count Combobox items

Do you want to count the PowerApps Combobox selected items? And for that, what you need to do? You can refer to this below code.

If you are interested to know more details about the PowerApps Combobox control, then follow this below article:

How to use PowerApps ComboBox control

  • In the below screenshot, there is a PowerApps ComboBox control having with these below items as:
Items = ["Earth", "Planet", "Sun", "Moon", "Star"]
PowerApps count Combobox items
PowerApps count Combobox items
  • Now I would like to count the items that have been selected by the user in the specific combo box control.
  • To do this, Add this below formula on Label’s Text property as:
Text = CountRows(ComboBox1.SelectedItems)

Where,

ComboBox1 = Combo box control name

PowerApps count Combo box items
PowerApps count Combobox items example
  • Save and Preview the app. Select the dropdown value as much you want, then the label will show you the output based upon your choice selection as shown in the below screenshot.
how to count PowerApps Combobox items
How to count PowerApps Combobox items

PowerApps count checkbox

Here we will see how we can count the Checkbox value in PowerApps.

NOTE:

Interested to know more about the PowerApps Checkbox control? Refer to this tutorial: PowerApps CheckBox – How to use
  • There is gallery control in the PowerApps app that is having with Product Details (where the items are retrieved from the SharePoint list).
  • If the product has been received (of a specific customer), then the checkbox will be checked otherwise it will not check as shown below.
  • Now I need to count the total number of check box value that has been checked in the gallery control.
PowerApps count checkbox
PowerApps count checkbox
  • I want to display the result in a Label control. So I added a Label (outside of the gallery control) and applied this below formula on its Text property as:
Text = CountRows(
    Filter(
        Gallery5.AllItems,
        Checkbox1.Value = true
    )
)

Where,

  1. Gallery5 = Gallery control name
  2. Checkbox1 = Check box control name
PowerApps count checkbox value
PowerApps count checkbox example
  • Save and Preview the app. You can see the result in the label control as in the above screenshot. As there are only three-box checked in the gallery, So the output is coming as 3.

PowerApps count choices

In this scenario, We will discuss how to work Powerapps count function with a SharePoint Choice column field. In the other scenario, We will see how to count names in a multiple selection people picker column.

Example – 1: (Count function with SharePoint Choice column)

  • On the Powerapps app, there is a gallery control. This control is having a SharePoint list data source named Project Details.
  • The SharePoint list (Project Details) is having a Choice column with these below choice values:
  1. Submitted
  2. Approved
  3. Rejected
  4. Pending
PowerApps count choices
PowerApps count choices
  • Here I want to count the total number of only Approved value that has been contained in the Sharepoint list. Not only approved value but also you can count the total number of Submitted, Pending, and Rejected values.
  • Apply this below formula on Label’s Text property as:
Text = CountIf(
    'Project Details',
    'Project Status'.Value = "Approved"
)

Where,

  1. ‘Project Details’ = SharePoint list name
  2. ‘Project Status’.Value = This specifies the SharePoint Choice column name. As it is a choice field, so we need to put the “.Value
  3. “Approved” = Specify the choice value that you need to count
  • As I have a total of two numbers of Approved items, that’s why the result is showing as 2 in the label control as below.
PowerApps count choice
PowerApps count choices example

Example – 2: (Count function with SharePoint People picker column)

  • The below screenshot represents the SharePoint list named Employee Info. This list has a Person or People picker column named Training Manager. Also, this list has some records.
PowerApps count choice values
How to count choices in PowerApps
  • There is an edit form in the PowerApps app and this form is having that specific SharePoint list data source (Employee Info).
  • Here I would like to count the total number of people i.e. selected by the user. To do so, I have applied this below formula on Label’s Text property as:
Text = "People selected: " & CountRows(DataCardValue7.SelectedItems)

Where,

  1. “People selected: “ = This is the text that will display in the label control
  2. DataCardValue7 = People picker data card name
PowerApps count choice value
PowerApps count choice values
  • Now Save and Preview the app. Once you will select any person(s) or user(s) from the people picker column, then you can see the result in the label control as shown in the below screensot.
Power Apps count choice values
Power Apps count choice values

PowerApps chart count

Do you want to know what is PowerApps Chart Count and how you can use it? Follow the below example.

  • I have a SharePoint list named MarkSheet. This ist has different types of columns with different data types as shown below.
  • Among them, I have a single line text column named “Pass Or Fail” that specifies a student is passed or failed.
PowerApps chart count
PowerApps chart count
  • On the Powerapps screen, I have a PowerApps gallery that has the “Pass or Fail” column. Here, I would like to count item based on the pass or fail column and display in a power apps chart.
  • For example, Pass or Fail = Pass, Fail. I want to count the total number of Pass and Fail records of students and display their count in a Powerapps chart.
  • To do so, Select the gallery control and apply this below formula on its Items property as:
Items = GroupBy(MarkSheet,"PassOrFail","MyCount")

Where,

  1. MarkSheet = SharePoint list name
  2. “PassOrFail” = SharePoint list column name
  3. “MyCount” = This is the group name that will help you to store the total number of count
PowerApps chart counts
PowerApps chart count
  • Select the text box from the gallery and set its Text property as:
Text = ThisItem.PassOrFail
how to use PowerApps chart count
PowerApps chart count example
  • Next, insert a Label control inside the Gallery control (as shown in the below screenshot) and put this below formula on its Text property as:
Text = "Total Number of Students: " & CountRows(ThisItem.MyCount)

Where,

MyCount = Group name that you have created before

use PowerApps chart count
how to use PowerApps chart count
  • Now to display the total number of student passed or failed, insert a Column chart (Insert -> Charts -> Column chart). Not only you can use only a Column chart but also you can use any chart like a Line chart, Pie chart, etc. as per your need.
  • Select the chart control and apply this below formula on its Items property as:
Items = Gallery7.Selected.MyCount

Where,

Gallery7 = Gallery control name

use Power Apps chart count
how to use PowerApps chart count
  • Save and Preview the app. Select the Pass from the gallery, you can see the chart will display the total number of passed students details.
  • Similarly, When you will select the Fail section from the gallery, then the chart will show the total number of failed students details as shown in the below screenshot.
how to use Power apps chart count
PowerApps chart count

PowerApps count dropdown items

Here we will see how to work a PowerApps Count function with a Dropdown control.

  • There is a Dropdown control on the PowerApps screen where the choice values are retrieved from the SharePoint list (MarkSheet).
  • In the SharePoint list, there is a choice column named Status. In this status column, it has two choice values as “Pass” and “Fail”.
  • To retrieve the SharePoint choice values to dropdown control, you can apply this below formula on its Items property as:
Items = Choices(MarkSheet.Status)

Where,

  1. MarkSheet = SharePoint list name
  2. Status = SharePoint choice column
PowerApps count dropdown items
PowerApps count dropdown items
  • Now I would like to count the total number of progress statuses depending upon the Dropdown control value. For example, if the user selects Pass value, then it will count the total number of only pass value (from the SharePoint list) and display in the label control.
  • Add a label control and apply this below formula on its Text property as:
Text = CountRows(
    Filter(
       MarkSheet,
       Status.Value = Dropdown2.Selected.Value
    )
)

Where,

Dropdown2 = Dropdown control name

PowerApps count dropdown item
PowerApps count dropdown items
  • Save and Preview the app. Select one choice value from the dropdown control, then you can see the total number of that specified items as per the dropdown choice.

PowerApps countdown timer

In this topic, By taking two different scenarios, We will discuss how to count down the time using PowerApps Timer control.

Example – 1:

  1. Suppose in the timer control, you want to display the time as like hours, minutes, seconds. Then you can put this below formula on its Text property as:
Text = Text(Time(0, 0, Timer1.Value/1000), "hh:mm:ss")
PowerApps countdown timer
PowerApps countdown timer

2. In most cases, you may think that is it possible to have the timer display the time of hours, minutes, seconds until it gets to 0.

Let’s take an example. Suppose there are events in your organization. If an event starts 24hrs from now, You want users to log into the app and see a counter counting down from 24:00:00 hours. As the logs into the app periodically, the time should still be counting down until 00:00:00.

To do so, You need to modify the Text property of the Timer to change what it displays. Timers have a Value and a Duration property. Set this below formula on its Text property as:

Text = Text(Time(0, 0, (Timer1.Duration-Timer1.Value)/1000), "[$-en-US]hh:mm:ss")
Power Apps countdown timer
PowerApps countdown timer

Now you can see, the timer control will display the time like 1minute with 00 seconds. Once you will hit the timer control, then it will count down from the backward directions, like 59 seconds, 58 seconds, and so on till it gets 00 seconds.

NOTE:

If you are interested to know more details about the PowerApps Timer control and its uses, then you can refer to this article: PowerApps Timer Control: How to use + start and reset with button

Example – 2:

In this scenario, We will see how to set the timer (with a specific time) with a progress bar status. Follow this below steps.

  1. On the PowerApps screen, Insert a Timer control and a Slider control.
  2. Put the Duration property of the Timer control (Timer2) as:
Duration = 30000
PowerApps countdown timer control
PowerApps countdown timer

3. Select the Timer control and set its Text property as:

Text = Text(Time(0, 0,(Timer2.Duration-Timer2.Value)/1000), "[$-en-US]hh:mm:ss")
use of PowerApps countdown timer
PowerApps countdown timer control

4. Put this below formula on the OnTimerEnd property of the Timer control as:

OnTimerEnd = UpdateContext({IsReset:false});UpdateContext({IsReset:true})
countdown timer in PowerApps
PowerApps countdown timer control

5. Set the Reset property to the Timer control as:

Reset = IsReset
countdown timer in Power Apps
countdown timer in Power Apps

6. Next in the Slider control, Insert this below formula on its Default property as:

Default = (Timer2.Duration-Timer2.Value)/1000
countdown timer PowerApps
countdown timer PowerApps

7. Set 30 to Slider’s Max property as like in the below screenshot.

countdown timer control PowerApps
countdown timer control PowerApps

8. Now Save and Preview the app. Click on the timer control, then you can see the time will decrease including the slider (progress bar) until it becomes 00:00:00. Suppose, for any reason, you want to pause the timer, then you can see the slider will also in pause mode.

Once the timer will down to 00:00:00, then it will restart again from 30seconds as like previous.

countdown timer control in PowerApps
countdown timer control in PowerApps

PowerApps count days in month

  • Here we will see how to get the last day of the month. The reason behind this is, whether we know if the last month got 28 days, 30 days, or 31 days.
  • You can get the last month by using the PowerApps Date function. If you set the day property to the number 0, then it will return the last day of the previous month. So if I wanted to get the last day of March, then follow the below formulas.
  • Set the below formula on Screen’s OnVisible property as:
OnVisible = Set(varEnd,Date(2021,4,0))
PowerApps count days in month
PowerApps count days in month
  • Next,Add a Date picker control and set this beow formula on its DefaultDate property as:
DefaultDate = varEnd
PowerApps count day in month
PowerApps count day in month
  • Save, Preview, and Publish the app. Once you will reopen the app, you can see the last day in the date picker control as shown in the above screenshot.

Also, you may like these below PowerApps Tutorials:

Hence in this PowerApps tutorial, We saw what is count function in PowerApps, What is its syntax, and how it works in the PowerApps app.

Also by taking some simple scenarios, We covered these below topics that are related to the PowerApps Count Function as:

  • PowerApps countA function
  • PowerApps CountA function Syntax
  • PowerApps CountA function Example
  • PowerApps count items in gallery
  • PowerApps count items in collection
  • PowerApps count items in sharepoint list
  • PowerApps count items in listbox
  • PowerApps count characters
  • PowerApps count filter
  • PowerApps count distinct or PowerApps count duplicates
  • PowerApps count attachments
  • PowerApps count array
  • PowerApps count button clicks
  • PowerApps count days between dates
  • PowerApps group by count rows
  • PowerApps count combobox items
  • PowerApps count checkbox
  • PowerApps count choices
  • PowerApps chart count
  • PowerApps count dropdown items
  • PowerApps countdown timer
  • PowerApps count days in month
>