Filtering Gallery using Radio Button

Requirement
Implementing Gallery data filtering using radio button.

Details
let’s say we have requirement to filter gallery data based on the selection of the radio button like below
filterapp1

To implement filter, I am using collection here and Dataverse Account entity as data source where I have records of different types (using Relationship Type attribute for customer category) so first let’s create two collection, one which will hold active accounts and another one where we will store filtered accounts based on the radio selection.
filterapp2

Now let’s place a radio button and change it’s Layout property to Horizontal and set Items property like below
filterapp3

Now let’s place a gallery control and set our second collection under Items property
filterapp4

By default you won’t see any data in the gallery control, to load data initially we can run OnStart manually like below
filterapp5

Now let’s place below expression Onselect property of radio control

If(
    currentfilter.Selected.Value = 1,
    ClearCollect(
        currentCollects,
        Filter(
            ActiveAccountsCols,
            'Relationship Type' = 'Relationship Type (Accounts)'.Customer
        )
    ),
    currentfilter.Selected.Value = 2,
    ClearCollect(
        currentCollects,
        Filter(
            ActiveAccountsCols,
            'Relationship Type' = 'Relationship Type (Accounts)'.Investor
        )
    ),
    currentfilter.Selected.Value = 3,
    ClearCollect(
        currentCollects,
        Filter(
            ActiveAccountsCols,
            'Relationship Type' = 'Relationship Type (Accounts)'.Partner
        )
    )
)

Finally let’s setup “Customer” under the Default property
filterapp6

Now filtering should work like below !
filterresult

Summary
This is how we can filter gallery control.

Hope it will help someone !!
Keep learning and Keep Sharing !!

Leave a Reply

Your email address will not be published. Required fields are marked *