Power Community

Power Community

Filter single choice column by 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:

ManishSolanki_10-1697383518845.png

Sample data

ManishSolanki_11-1697383614149.png

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:

ManishSolanki_1-1697379025007.png

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

ManishSolanki_2-1697379221501.png

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:

ManishSolanki_3-1697379272248.png

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:

ManishSolanki_4-1697380867792.png

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

ManishSolanki_5-1697380978788.png

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:

ManishSolanki_6-1697381094806.png

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:

ManishSolanki_7-1697381651646.png

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

ManishSolanki_8-1697382676845.png

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.

This post was originally published on this site

- Advertisement -spot_img

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement - Advertisement

Latest News

Maplytics Optimizes Routes and Boosts Productivity for T-GREX

T-GREX, a company founded by brothers Roberto and Matteo, brings together their 30 years of experience in the precision...

More Articles Like This

- Advertisement -spot_img