Dataverse Power Automate
Manish Solanki  

Filter single select choice field by label text in Dataverse

Use Case

Recently, I came across a problem of filtering the records by choice text (label text) from Dataverse table. This is a common query posted by users in Power Platform community. So, I decided to write this blog and explain the ways to address this problem.

Please note that below solution will work only for single select choice field.

Scenario

Let’s take an example of a custom table ‘Employee’. This table has column ‘Type’ as a single select choice field:

Sample data

Solution

Firstly, get the logical name of the choice field. To get the column name, go to table details screen and click “Columns” under ‘Schema’ section:

Next, scroll down to locate the column name & click its name:

Scroll down & click “Advanced options” to expand it. Once it is expanded, you can see the logical name of the choice column. Copy & save it as logical name will be used in the filter query:

In this example, I have created a manual trigger flow that accepts “Employee Type” value from the user. Based on the input value, it performs filter operation on the choice field.

I have transformed text input parameter to drop down list and provided the options in the list:

Now, add “List rows” action to get the records from the “Employee” table:

Next, we will add the “Filter array” action to perform the filter operation. Pass the array ‘value” from the List rows action in the “From” parameter. In the filter query, on the left side of equal to operator, add an expression that will compare the text of choice field:

Expression used for the left-hand operand:

item()['crc76_type@OData.Community.Display.V1.FormattedValue']

where, crc76_type is the logical name of the choice column which we have found & copied in the initial steps.

Compare the value with the input parameter from manual trigger action by entering it on the right side of the filter query.

The output body of filter array action will return the desired filter array.

Output after flow execution

From manual trigger flow, “Permanent” value has been chosen as input parameter:

The array resulted from Filter array action is the desired output:

Conclusion

As explained in the above steps, filtering records by choice field label cannot be performed directly using filter query in “List rows” action. We need to first read all the records and then apply filter query in “Filter array” action.

Leave A Comment