Adding a filter to a Power Apps gallery restricts the data shown to only the records that match specific criteria, allowing users to find information quickly and reducing the amount of data the app needs to process. To do this, you must access the gallery's properties pane and modify the Items property to include a Filter function applied to the data source. This does not require any external software or accounts beyond a standard Microsoft 365 or Power Apps subscription, but you do need a data source like SharePoint, Dataverse, or SQL connected to the app.

What You'll Need

  • A Microsoft 365 account with access to Power Apps.
  • A data source (such as a SharePoint list, Dataverse table, or Excel Online) connected to your app.
  • The Power Apps Maker portal or the Power Apps mobile app to edit the application.
  • Basic knowledge of the data source's fields and the types of data stored within them.

Step-by-Step

  1. Open your Power App: Launch the Power Apps Maker portal in your web browser. Locate the app you wish to edit in the left-hand pane under the "Apps" section and click on it to open it in full-screen view.
  2. Select the Gallery: On the canvas, click directly on the gallery control you want to filter. It is important to select the gallery itself, not an individual card or label inside it. If you are using a blank gallery, you may need to add a data card first by dragging a field from the data pane onto the canvas, but the selection still targets the gallery container.
  3. Open the Properties Pane: With the gallery selected, look at the right-hand side of the screen. Click on the "Properties" tab or the icon that looks like a small square with lines (often labeled "Properties") to open the property editor pane.
  4. Locate the Items Property: In the property editor pane, scroll down to the Items property. This is the key setting that determines which data is displayed in the gallery.
  5. Modify the Items Formula: The Items property currently contains a reference to your data source, such as MyDataSource or Filter(MyDataSource, Status = "Active"). You need to change this to include the Filter function. Type Filter( followed by your data source name. For example, if your data source is a SharePoint list called "Projects", the start of your formula will be Filter('Projects', ....
  6. Define the Filter Criteria: Inside the parentheses of the Filter function, define the logic for what should be shown. You can use comparison operators like = (equals), > (greater than), < (less than), >=, <=, or <> (not equals). You can also use logical operators like And, Or, and Not to combine conditions.
  7. Combine with User Input (Optional but Recommended): To make the filter dynamic and useful, you should often reference controls on your screen. For example, if you have a text input box on your screen named SearchBox, you can filter to show only projects that match the text in the box. The formula would look like this: Filter('Projects', TextSearchBox.Text in Title). The in operator checks if the text box value is contained within the Title field.
  8. Save and Test: Once you have entered your formula, press Enter on your keyboard to save the property. The gallery on the canvas will immediately update to reflect your changes. Click the "Play" button at the top of the screen to test the app in preview mode. Enter different values into your input controls to ensure the gallery filters correctly.

Common Mistakes

One of the most frequent errors is attempting to filter the gallery by selecting a label or a specific card *inside* the gallery rather than the gallery container itself. This will do nothing because the inner controls inherit their data from the container. Always select the large rectangle or box that holds the items to edit the Items property.

Another common mistake is using a text input box directly in the filter without accounting for empty states. If the user deletes the text in the search box, the filter might still be active. It is best practice to wrap the filter logic in a If statement or use the IsBlank function to return all records when the input is empty.

Tips

For better performance, especially with large datasets, it is highly recommended to use the StartsWith function instead of Contains when searching through text fields, as it is optimized for database lookups. Additionally, if you have a complex filter involving many conditions, it is often cleaner to define the criteria in a separate variable using the UpdateContext function. This makes the main Items formula shorter and easier to read. For example, you can set a context variable varFilterText when the search button is clicked, and then simply use Filter('Projects', StartsWith(Title, varFilterText)).

Troubleshooting

If the gallery is not showing any items after you have added the filter, the most likely cause is a syntax error in the formula. Check for missing parentheses, quotes around text strings, or incorrect field names. The Power Apps formula bar often turns red to indicate a syntax error. Another possibility is that the data source connection has been lost. Check the Settings > Connections section of the Maker portal to ensure your data source is still connected.

If the gallery filters correctly but the sort order seems random, you may need to add a SortByColumns function to the end of your formula. For example: Filter('Projects', Status = "Active") then sort by the Title field to ensure consistent results.

Frequently Asked Questions

Can I filter a gallery by multiple fields at the same time?

Yes, you can filter by multiple fields by using the And operator. For instance, Filter('Projects', Status = "Active" And Priority = "High") will only show projects that are both active and high priority.

How do I make the filter case-insensitive?

By default, filtering is case-sensitive. To make it case-insensitive, you can convert both the field value and the search text to lowercase using the Lower function. For example: Filter('Projects', Lower(Title) = Lower(txtSearch.Text)).

What if my data source is a SharePoint list with a complex column type?

SharePoint has specific column types like Person or Choice. When filtering a Person column, you must use the IsBlank function to check for the user. For Choice columns, you must use the Value function to access the underlying text value. For example, Filter('Projects', IsBlank(CreatedBy)) or Filter('Projects', Value(Status) = "In Progress").

How do I clear the filter when the screen loads?

To reset the filter to show all records when the user opens the screen, you can use the ClearCollect function inside the OnStart of the screen or the OnVisible property of the screen. Alternatively, you can use a button that resets the value of your search text input to an empty string.

Can I use a dropdown to filter a gallery?

Absolutely. You can bind the Items property of a dropdown control to the unique values of a specific column in your source. Then, in the gallery's Items property, you can filter based on the dropdown's selected value: Filter('Projects', Category = Dropdown1.Selected.Value).