How to Filter Power Apps Data Table using Checkbox?

It is quite tricky to filter the data table control using a Power Apps check box control. But yes, the code is very simple, and it is easy to achieve this.

In this article, I will explain how to filter Power Apps data table using check box. Also, we will know how to filter the data table control using multiple checkboxes in Power Apps.

How to Filter Power Apps Data Table using Checkbox

Let’s take a simple scenario.

I have a SharePoint Online list, i.e., [Travel Requests], which contains various columns. Apart from all the columns, I have a Yes/No column [Approved], as shown below.

How to Filter Power Apps Data Table using Checkbox

The checkbox control will show the Yes/No field values each time the user adds a new field to the Power Apps data table. However, all checkboxes will be checked by default, as seen below.

How to Filter the Power Apps Data Table using Checkbox

Select the Checkbox field [Approved] to resolve this and set its Text property as blank. Then, you will get the respective SharePoint list “Yes/No field” values as shown below.

Filter a Power Apps Data Table using Checkbox

In Power Apps, there is a checkbox control above the data table. The data table filters and displays all the checked items whenever the user selects the ” Is Approved ” checkbox.

In the same way, if the user unchecks or does not select the checkbox, then the data table will filter and display only unchecked items.

Have a look at the below screenshot for the output.

Filter Power Apps Data Table using Checkbox

To work around this, follow the below steps.

See also  Power Apps Upload File to SharePoint Document Library

1. Open Power Apps -> Create a Blank Canvas app and connect it to the specific SharePoint Online list [Travel Requests] like below.

Filter the Power Apps Data Table using Checkbox

2. On the Power Apps Screen -> Insert a Checkbox control and set its Text property as:

Text = "Is Approved"
Filter Power Apps Data Table using Checkbox Control

3. Then, insert a Data table control and set its Items property to the code below.

Items = Filter(
    'Travel Requests',
    Approved = chk_Approved.Value
)

Where,

  • Filter() = We can use Filter to find a set of records that match one or more criteria
  • ‘Travel Requests’ = SharePoint Online list
  • Approved = SharePoint list Yes/No field
  • chk_Approved = Power Apps checkbox name
Filter a Power Apps Data Table using Checkbox Control

4. Once your app is ready, Save, Publish, and Preview the app. When the user selects or checks the “Is Approved” checkbox control, the data table will filter and display only checked items like below.

This way, you can filter the Power Apps data table using a single checkbox control.

Filter Power Apps Data Table using a Checkbox Control

Filter Power Apps Data Table using Multiple Checkboxes

This section will see how to filter the Power Apps data table using multiple checkboxes.

Scenario:

In Power Apps, there are three check box controls [Not Started, In Progress, and Completed] and a data table control that retrieves the records from a collection [colProjects].

The data table will filter and show only in-progress records when the user checks the “In progress” checkbox.

Filter Data Table using Checkbox in Power Apps

To achieve it, follow the below steps:

1. On the Power Apps Screen -> Insert three checkbox controls and set their OnSelect property as:

OnSelect = Set(
    gblFilterProjects,
    Self.Text
)

Where,

  • gblFilterProjects = Power Apps Global Variable Name
How to Filter Data Table using Checkbox in Power Apps

2. Next, insert a Data table control and set its Items property to the code below.

Items = Filter(
    colProjects,
    Status.Value = gblFilterProjects
)

Where,

  • colProjects = Power Apps collection
  • Status = Collection choice field
Filter PowerApps Data Table using Multiple Checkboxes

3. Save, Publish, and preview the app. If the user selects the “Not started checkbox”, the data table filters and displays not started records. And, if the user selects another checkbox again, like the Completed check box, then the data table will only display completed records.

Filter Power Apps Data Table using Multiple Checkboxes

4. But, it should be not like this, to overcome this issue, set the variable to all checkboxes. For that, select the App object and set its Onstart property as:

OnStart = Set(varNotStarted,true);
Set(varInProgress, false);
Set(varCompleted, false)

Where,

  • Set() = This function is used to set a global variable to the entire app
  • varNotStarted, varInProgress, varCompleted = Variable Names
How to Filter PowerApps Data Table using Multiple Checkboxes

5. Now, select the three Checkbox controls and set their Default and OnCheck properties as shown below.

Default = varNotStarted
OnCheck = Set(
    varNotStarted,
    true                                                                    //For chk_NotStarted
);
Reset(chk_InProgress);
Reset(chk_Completed)

Default= varInProgress
OnCheck = Set(
    varNotStarted,
    false                                                                 //For chk_InProgress
);
Reset(chk_NotStarted);
Reset(chk_Completed)

Default = varCompleted
OnCheck = Set(
    varNotStarted,
    false                                                                //For chk_Completed
);
Reset(chk_InProgress);
Reset(chk_NotStarted)

Where,

  • chk_NotStarted, chk_InProgress, chk_Completed = Power Apps checkbox names
  • Reset() = This function is used to reset a control to its Default property value
How to Filter Power Apps Data Table using Multiple Checkboxes

6. Once your app is ready, SavePublish, and Preview the app. The data table filters and displays each record from the collection based on the checkbox selected value.

Filter a Power Apps Data Table using Multiple Checkboxes

This way. we can filter the Power Apps data table using multiple checkboxes.

See also  Power Apps Update Data Table [With Examples]

I hope you got an overall idea of how to filter the Power Apps data table control using a single check box and multiple checkboxes with different scenarios.

Also, you may like some more tutorials:

>