How to Filter Gallery By Radio Button in Power Apps?

Do you want to filter a Power Apps gallery by radio button? Check out this complete tutorial; I have explained how to filter gallery by radio button in Power Apps.

I will show you how to bind the SharePoint list choice field in a Power Apps Radio button and filter a Power Apps gallery based on that Radio button selected value.

Power Apps Filter Gallery By Radio Button

Let’s see how to filter a Power Apps gallery by the Radio button selected value with a simple scenario.

Scenario:

I have a SharePoint Online list, i.e., [Product Details], and this list contains the below fields.

Column NameData Type
Product NameIt is a default single line of text, I just renamed it as “Product Name”
ManufacturerThis “Choice” field has the following values. Such as: “Sony“, “Samsung“, and “Apple
PriceCurrency
Purchase DateDate and time
Power Apps Filter Gallery By Radio Button

In Power Apps, I have added a Gallery control and a Radio button control. Whenever a user selects any value, i.e., [All, Sony, Samsung, Apple] from the Power Apps Radio button, it will filter the SharePoint choice field and display the respective records on the gallery control.

Refer to the below image:

Power Apps Filter Gallery By Radio Button Control

To work around this, follow the below-mentioned steps. Such as:

1. Open Power Apps with your respective Microsoft -> Create Power Apps Canvas app and connect to the SharePoint list -> Once you connect, it will appear under the Data section.

Power Apps Gallery Filter By the Radio Button

2. Go to the Power Apps Screen -> Insert a Gallery control and set its Items property as:

Items = 'Product Details'

Where,

  • ‘Product Details’ = SharePoint Online List
Filter Power Apps Gallery By Radio Button

3. Now, we want to display the SharePoint list records based on the Power Apps Radio button selected value. For that, insert a Radio button control and set its Items property to the code below.

Items = Choices([@'Product Details'].Manufacturer)

4. Whenever we add a SharePoint list choice field in the Radio button, it will take only the respective SharePoint choice field values as shown below.

Filter Power Apps Gallery By Radio Button Control

5. But, if you want to add a value [“All”] to display all records on the gallery control, then set the Power Apps Screen’s OnVisible property code.

OnVisible = ClearCollect(
    colProducts,
    {Value: "All"}
);
Collect(
    colProducts,
    Distinct(
        'Product Details',
        Manufacturer.Value
    )
)

Where,

  • colProducts = Power Apps Collection Name
  • “All” = Collection Value
  • ‘Product Details’ = SharePoint Online List
  • Manufacturer = SharePoint Choice Field
Power Apps Gallery Filter By Radio Button Control

6. Now, select a Radio button control and change its Items property to the code below.

Items = colProducts

Where,

  • colProducts = Power Apps Collection Name
How to Filter Power Apps Gallery By Radio Button

7. Also, select a Gallery control and change its Items property as shown below:

Items = If(
    Radio_Manufacturer.Selected.Value = "All",
    'Product Details',
    Filter(
        'Product Details',
        Manufacturer.Value = Radio_Manufacturer.Selected.Value
    )
)

Where,

  • If() = This function helps us to evaluate multiple unrelated conditions
  • Radio_Manufacturer = Power Apps Radio Button Name
How to Filter Power Apps Gallery By Radio Button Control

8. In the last, set the Radio button control default value as “All“. So, whenever the user opens the app, the gallery control will display “All items” as shown below.

Default = "All"
How to Filter a Power Apps Gallery By Radio Button

9. Once your app is ready, just Save, Publish, and Preview the app. When the user selects any value from the Radio button, the gallery control will display all records based on the Radio button selected value as in the screenshot below.

How to Filter the Power Apps Gallery By Radio Button

This is how to filter a Power Apps gallery by Radio button control.

Conclusion

Wherever you want to filter a Power Apps gallery by the Radio button, you can use the Filter() function to achieve it.

From this Power Apps tutorial, we learned how to bind the SharePoint list choice field in a Radio button control and how to filter a Power Apps gallery by the Radio button with a complete example.

You may also like: