cancel
Showing results for 
Search instead for 
Did you mean: 
ManishSolanki

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.

Comments

So I guess the correct conclusion is don't use choice fields use text fields instead so that you can just retrieve the data you want? To do it the way above you may have to retrieve a huge amount of data and only then filter. Which is less than idea.

About the Author
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • Read more about me and my achievements at: https://ganeshsanapblogs.wordpress.com/about MCT | SharePoint, Microsoft 365 and Power Platform Consultant | Contributor on SharePoint StackExchange, MSFT Techcommunity
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Founder of SKILLFUL SARDINE, a company focused on productivity and the Power Platform. You can find me on LinkedIn: https://linkedin.com/in/manueltgomes and twitter http://twitter.com/manueltgomes. I also write at https://www.manueltgomes.com, so if you want some Power Automate, SharePoint or Power Apps content I'm your guy 🙂
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 15 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #M365 #Power Platform| Microsoft MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – https://kamdaryash.wordpress.com Youtube channel - https://www.youtube.com/channel/UCM149rFkLNgerSvgDVeYTZQ/