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
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.
Among them, there is a Choice field called Gender. This gender field has four choices: Male, Female, Transgender, and Others.
The image below represents all the records of the specific table.
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.
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.
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:
‘Select Gender‘ = This is the display name of the choice field that contains all the choice values stored in the Dataverse table.
Male = Specify a choice value from the choice field that you want to filter.
Refer to the screenshot below.
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.
To achieve this, set the Combobox Items property to the code below:
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.
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.’.
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:
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.
Next, apply the code below on the gallery’s Items property:
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 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.
To work with this, set the code below on the Dropdown’s Items property as:
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.“
To achieve this, set the Items property of the Dropdown control as:
‘Select Gender’ = It is the display name of the choice field where all the choice values are stored in the Dataverse table
Male, Female, Transgender, Others = These are the choice values that stored in the Select Gender field
“Registration Successful“, “Registration Unsuccessful” = Messages that display in the text input control based on the condition
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:
Hey! I’m Bijay Kumar, founder of SPGuides.com and a Microsoft Business Applications MVP (Power Automate, Power Apps). I launched this site in 2020 because I truly enjoy working with SharePoint, Power Platform, and SharePoint Framework (SPFx), and wanted to share that passion through step-by-step tutorials, guides, and training videos. My mission is to help you learn these technologies so you can utilize SharePoint, enhance productivity, and potentially build business solutions along the way.