Filter Power Apps Gallery By Dataverse Choice Column [With Various Examples]

A few days ago, I needed to filter a gallery based on a Dataverse Choice field. I had a dropdown in Power Apps that showed all the Dataverse choices, and whenever a user picked an option, the gallery had to filter based on that selection.

In this Power Apps tutorial, I will explain how to filter Power Apps gallery by Dataverse choice column step by step. Also, we will discuss some more topics like:

  • Filter Gallery with a specific Dataverse choice value
  • Filter the Dataverse Choice column using Power Apps Combo Box
  • Filter the Dataverse choice column by text value
  • Filter the Dataverse Choice Column by the Dropdown control
  • Filter Power Apps Data table by Dataverse choice value
  • Get the Dataverse choice field value in Power Apps

So let’s get started.

Filter Power Apps Gallery By Dataverse Choice Column

The screenshot below shows a Dataverse table called Job Seekers Registration List with multiple columns. When you open the Columns section, you can see all the fields that are part of this table.

Filter Dataverse Choice Column

Among them, there is a Choice field called Gender. This gender field has four choices: Male, Female, Transgender, and Others.

Filter gallery by dataverse choice column

The image below represents all the records of the specific table.

Filter PowerApps gallery by dataverse choice column

Now we will filter the Power Apps gallery based on this Dataverse choice field, i.e., Gender. To achieve it, follow the instructions below:

NOTE:

Before that, we must connect the Dataverse table to Power Apps.

To connect the Dataverse table (Job Seeker Registration List), go to the Home tab and open the Data panel on the left. Click Add data -> Select Dataverse table from the Tables list. Once you add it, the table will be available to use in Power Apps.

Connect Dataverse to Power Apps

Below, you can see the Power Apps gallery Items property set to the Dataverse table. Now I would like to filter the gallery based on the Dataverse choice value.

Display Dataverse Records in Power Apps Gallery

Now, I will show you how to filter the Power Apps gallery with a particular Dataverse choice value. We want to display only the Dataverse records where the gender is Male and show them in a gallery.

To do this, select the gallery and update its Items property with the formula below:

Items = Filter(
    'Job Seekers Registration Lists',
    Gender = 'Select Gender'.Male
)

Where,

  1. Gender = Specify the Dataverse choice column
  2. Select Gender‘ = This is the display name of the choice field that contains all the choice values stored in the Dataverse table.
  3. Male = Specify a choice value from the choice field that you want to filter.

Refer to the screenshot below.

Filter Dataverse Records with a Specific Choice

Filter Gallery By Dataverse Choice Value [Using Power Apps Combo Box]

Next, we’ll look at how to filter a Power Apps gallery by a Dataverse choice field value using a Combo box.

The screenshot below shows a Power Apps Combo box and a Gallery. When a user selects a gender from the Combo box, the gallery updates and displays only the records that match that selection.

For example, if the user chooses Female, the gallery will show only the records where the gender is Female.

Filtering Dataverse Choice using PowerApps ComboBox
  1. To achieve this, set the Combobox Items property to the code below:
Items = Distinct(
    'Job Seekers Registration Lists',
    Gender
)

Where,

Distinct = This function specifies to retrieve only the unique values

Filter Dataverse Choice using Power Apps Combo Box
  1. Next, select the gallery control and set its Items property as:
Items = Filter(
    'Job Seekers Registration Lists',
    Gender = cbGender.Selected.Result
)

Where,

cbGender = Combo box control name

Filter Dataverse Choice column using Combo Box

Save, publish, and preview the app. When you select a gender from the Combo box, the gallery filters and displays records based on the selected option.

Filter Power Apps Gallery By Dataverse Choice [Using Text Value]

Let’s say we want to filter all records where the Gender is ‘Others.’ Since Gender is a Choice column, we can’t filter it directly with a plain-text value. This data type mismatch is why the filter doesn’t work.

In the screenshot below, the formula is written correctly, but it still doesn’t return any results in the gallery because of this issue.

Filter Dataverse Choice Column by the Text Value

Similarly, you can’t compare a Choice column to a value returned from a LookUp function. Even though the formula looks correct and logically should work, Power Apps treats the data types differently.

As shown in the image below, when we apply the formula in the gallery’s Items property, it gives an error saying: ‘Incompatible types for comparison. These types can’t be compared: OptionSetValue(Select Gender), Record.’.

Items = Filter('Job Seekers Registration Lists',Gender=LookUp(Choices('Job Seekers Registration Lists'.Gender),Text(Value)="Others"))
Filter Dataverse Choice Column by the Text

SOLUTION:

As a workaround, we can use a hidden Power Apps Dropdown control. The idea is that even though LookUp can’t directly filter a choice column, it can filter based on the value selected in a dropdown.

  • For example, if a user types a gender into the txtEnterGender text input box, we can pass that value into a hidden dropdown and use it to filter the records.
  • Add a Dropdown control to the screen and set its Items property to the code below:
Items = Filter(
    Choices('Job Seekers Registration Lists'.Gender),
    Text(Value) = txtEnterGender.Text
)

Where,

Text(Value) = Power Apps Function name that helps to convert a Choice to Text. To know more about this function, refer to this complete tutorial: Power Apps Value Function

  • Once we applied the code to the Dropdown, we need to set the Visible property to false. So that nobody can see this Dropdown control in the app.
Filtering Dataverse Choice Column by Text Value
  • Next, apply the code below on the gallery’s Items property:
Items = Filter(
    'Job Seekers Registration Lists',
    Gender = ddSelGender.Selected.Value
)

Where,

ddSelGender = Dropdown control name

How to filter Dataverse Choice Column by Text Value
  • Finally, save, publish, and preview the app. Now, when the user types any gender value in the text input box, the gallery will show the records that match that value, as shown below.
filter Dataverse Choice Column by powerapps text input

Filter Gallery By Dataverse Choice Value [Using Power Apps Dropdown]

Now I will show you how to filter a Power Apps gallery by a Dataverse choice field using a Dropdown control.

In the example below, there is a Dropdown control and a Gallery control. When a user selects a gender, for example, Others, the gallery filters automatically and shows only the items that match the chosen gender.

Filter Dataverse Choice by Dropdown
  • To work with this, set the code below on the Dropdown’s Items property as:
Items = Choices('Job Seekers Registration Lists'.Gender)

Where,

Choices = This Power Apps function helps to return a table of the possible values for a lookup column.

Filter the Dataverse Choice Column by Dropdown
  • Next, set the Gallery’s Items property to the following formula:
Items = Filter(
    'Job Seekers Registration Lists',
    Gender = ddGender.Selected.Value
)

Where,

ddGender = Dropdown control name

dataverse choice column by dropdown control

This way, we can filter the Power Apps gallery by the Dataverse Choice field using the Dropdown control.

Filter Power Apps Data Table By Dataverse Choice Value

Let’s see how we can filter the Power Apps Data table by the Dataverse choice field value.

When a user selects a value from the dropdown, the data table shows only the records that match that selection.

For example, if the user picks Others from the dropdown, the data table will display only the entries where the gender is Others.

Power Apps get value of Choice field
  • Select the Dropdown control and set its Items property as:
Items = Choices('Job Seekers Registration Lists'.Gender)
powerapps get value of choice field dataverse
  • Then, select the Data table and apply the formula below to its Items property:
Items = Filter(
    'Job Seekers Registration Lists',
    Gender = [@ddSelectGender].Selected.Value
)

Where,

ddSelectGender = Dropdown control name

Power Apps get value of choice field dataverse
  • Save, publish, and preview the app. Select any value from the dropdown, the gallery will filter and show the result accordingly.

Get Dataverse Choice Field Value in Power Apps

The screenshot below shows a Power Apps dropdown control and a text input box. The dropdown lists all the Dataverse gender options: Male, Female, Others, and Transgender.

If the user selects Male or Female, the text input box will show the message “Registration Successful.”

If the user selects Others or Transgender, the text input box will show “Registration Unsuccessful.

Get value of Choice field Dataverse
  • To achieve this, set the Items property of the Dropdown control as:
Items = Choices('Job Seekers Registration Lists'.Gender)

Where,

Gender = Dataverse Choice Column Name

Dataverse get value of Choice field
  • Next, select the Text input control and apply the code below to its Default property:
Default = If(
    ddChooseGender.Selected.Value = 'Select Gender'.Male,
    "Registration Successful",
    If(
        ddChooseGender.Selected.Value = 'Select Gender'.Female,
        "Registration Successful",
        If(
            ddChooseGender.Selected.Value = 'Select Gender'.Transgender,
            "Registration Unsuccessful",
            If(
                ddChooseGender.Selected.Value = 'Select Gender'.Others,
                "Registration Unsuccessful"
            )
        )
    )
)

Where,

  1. ddChooseGender = Name of the Dropdown control
  2. ‘Select Gender’ = It is the display name of the choice field where all the choice values are stored in the Dataverse table
  3. Male, Female, Transgender, Others = These are the choice values that stored in the Select Gender field
  4. Registration Successful“, “Registration Unsuccessful” = Messages that display in the text input control based on the condition
Dataverse get value of Choice field in Powerapps gallery

Finally, save, publish, and preview the app. Select any Dataverse choice option from the dropdown, and the text will appear accordingly.

I hope this article helped you to learn how to filter the Power Apps Gallery by the Dataverse Choice column with a few examples, like filtering the gallery with a specific Dataverse choice value, filtering the Dataverse Choice column using a Power Apps Combo Box, Text value, and many more.

Additionally, you may like some more Power Apps Dataverse tutorials:

Leave a Comment

Power Apps functions free pdf

30 Power Apps Functions

This free guide walks you through the 30 most-used Power Apps functions with real business examples, exact syntax, and results you can see.

Download User registration canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App