How to Filter List Box in Power Apps?

Filtering data and displaying the results in controls such as galleries and data tables is a regular task when dealing with Power Apps.

I was recently working with Power Apps List box control, where I needed to filter the SharePoint list data and display the result in a gallery control.

In this article, I will explain to you how to filter list box in Power Apps, including various examples like:

  • Power Apps filter list box using the SharePoint Choice field
  • Power Apps filter list box using the SharePoint Date field
  • Power Apps filter list box and search

How to Filter List Box in Power Apps

So, let’s start with filtering the Power Apps list box control with the scenarios below.

Power Apps filter list box using SharePoint Choice column

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

Column NameData Type
Project NameThis is a Title column with a single line of text. I just renamed it to “Project Name”
DescriptionMultiple lines of text
Project StatusChoice
Start DateDate and time
End DateDate and time

Refer to the below screenshot:

filter powerapps listbox items

In Power Apps, there is a List box control and a Gallery control. The List box control has all the list choice values like All, In Progress, Not Started, and Completed.

The gallery will filter and show all records from the SharePoint list based on the user’s selections when they choose any value from the List box control.

See also  Create Collection in Power Apps [With Examples]

Refer to the below image:

how to filter powerapps list box items

To achieve this, follow the instructions below:

1. Open Power Apps -> Create Power Apps canvas app -> Connect the SharePoint list [Project Tracker] to the app. Once you connect, it will look like the screenshot below.

filter power apps listbox items

2. Select the Power Apps Screen [ProjectTrackerScreen] -> Set its OnVisible property to the code below.

OnVisible = ClearCollect(
    colProjects,
    {Value: "All"}
);
Collect(
    colProjects,
    Distinct(
        'Project Tracker',
        'Project Status'.Value
    )
)

Where,

  • colProjects = Power Apps Collection
  • {Value: “All”} = Collection Item
  • Distinct() = This function can remove duplicate values from a data source
  • Project Tracker’ = SharePoint Online List
  • ‘Project Status’.Value = SharePoint Choice Field Column Values
filter powerapps list box items

3. Next, insert a List box control [ListBox_ProjectStatus] -> Set its Items property as:

Items = colProjects

Where,

  • colProjects = Power Apps Collection
how to a filter powerapps listbox items

4. Insert a Gallery control and set its Items property as shown below:

Items = If(
    ListBox_ProjectStatus.Selected.Value = "All",
    'Project Tracker',
    Filter(
        'Project Tracker',
        'Project Status'.Value = ListBox_ProjectStatus.Selected.Value
    )
)

Where,

  • If() = This function helps us to evaluate multiple unrelated conditions
  • ListBox_ProjectStatus.Selected.Value = “All” = Power Apps List box name, and “All” is the collection item value
how to a filter power apps listbox items

5. Save, Publish, Reload, and Preview the app. The gallery will show all completed records if the user selects the status Completed from the list box.

how to filter the powerapps list box items

This is how to filter the Power Apps List box control using a SharePoint choice field.

Power Apps filter list box using SharePoint Date column

Next, we will discuss how to filter a Power Apps List box selected date with a simple example.

Example:

1. I have a SharePoint Online list named “Training Courses“. This list contains the below fields.

Column NameData Type
Course NameThis is a Title column with a single line of text. I just renamed it to “Course Name”
DescriptionMultiple lines of text
Course Start DateDate and time
Course End DateDate and time
filter power apps list box items

In Power Apps, there is a List box control and a Data table control. The Data table control displays each record from the SharePoint list based on the List box selected date.

See also  Power Apps Dropdown Control - How to use

Refer to the below screenshot:

power apps filter listbox selected date

To work around the above example, follow the below steps.

1. On the Power Apps -> Connect the SharePoint list, i.e., [Training Courses] to the app. Once you connect, it will look like the screenshot below.

how to filter powerapps listbox items

2. Insert a List box control and set its Items property to the code below.

Items = Distinct(
    'Training Courses',
    'Course Start Date'
)

Where,

  • ‘Training Courses’ = SharePoint Online List
  • Course Start Date’ = SharePoint Date Field
how to filter power apps listbox selected date

3. Then, insert a Data table control and set its Items property as:

Items = Filter(
    'Training Courses',
    'Course Start Date' = ListBox_TrainingCourses.Selected.Value
)

Where,

  • ‘Training Courses’ = SharePoint Online List
  • ListBox_TrainingCourses = Power Apps List Box Name
how to filter power apps list box selected date

4. Save, Publish, and Preview the app. Select any particular date from the List box control, the Data table displays the records based on the List box selected date.

power apps filter list box selected date

This is all about the Power Apps Filter List box selected date.

Power Apps filter list box and search

Last, we will see how to filter a Power Apps list box and display records on the data table based on search.

Example:

I will also take the same SharePoint Online list [Training Courses] for this example. In Power Apps, there is a List box control, a Text input, and a Data table control.

This Data table displays each record from the SharePoint list based on the List box control and search results.

Also, I faced a delegation warning [Yellow triangle], as in the screenshot below. The warning message appears as “Delegation warning. This formula’s “Search” part might not work correctly on large data sets.

filter listbox items in power apps

I have created a Power Apps collection [colCourses] using my SharePoint list to overcome this Power Apps delegation warning. Then, I filter a Power Apps data table by the List box control without delegation warning like below.

filter listbox items in powerapps

To do so, follow the below steps. Such as:

See also  Create Hyperlink Button in Power Apps

1. On the Power Apps canvas app -> Select the App object and set its OnStart property to the code below.

OnStart = ClearCollect(
    colcourses,
    'Training Courses'
)

Where,

  • colcourses = Power Apps Collection Name
  • ‘Training Courses’ = SharePoint Online List
how to filter power apps listbox items

2. Insert a Text input, make its Default property blank [“”], and set its Hint text property as “Search Course Name” like below.

how to filter listbox items in powerapps

3. Then, insert a List box control and set its Items property as:

Items = Distinct(
    colcourses,
    'Course Start Date'
)

Where,

  • colcourses = Power Apps Collection
  • ‘Course Start Date’ = SharePoint Date Field
how to filter list box items in powerapps

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

Items = Search(
    Filter(
        colcourses,
        'Course Start Date' = ListBox_Courses.Selected.Value
    ),
    txt_Search.Text,
    "Title"
)

Where,

  • Search() = This function allows users to search for and filter items in a Power Apps gallery
  • ListBox_Courses = Power Apps List Box
  • txt_Search.Text = Power Apps Text input
  • “Title” = SharePoint Text column
PowerApps filter list box and search

5. Save, Publish, Run OnStart, and preview the app. This data table will display the filtered records based on the search results and selected List box value, as in the screenshot below.

filter list box items in power apps

This is how to filter a Power Apps List box and search.

I hope you got an overall idea to filter the Power Apps list box control using various SharePoint fields like Choice, Date, etc.

Also, we saw how to search and filter the Power Apps list box together with a simple example.

You may like some more Power Apps articles:

>