How to filter a datasource in Canvas app based on Choice/ Optionset field

This blog is short and simple. And quite a common requirement I guess.

How do I filter a datasource in canvas app based on Choice field? If you have worked on Canvas app, you must have used the Filter function. And sometimes in that filter you shall need to use a Choice field value as of one the filters.

For my example, I am going to use DataVerse as data source. However the same shall work for Choice fields from other data sources.

I have a table in DataVerse named – ‘Device Orders’ which have a choice field named – ‘Order Status’. It has three values.

  1. Pending Approval
  2. Approved
  3. Rejected
Filter a datasource in Canvas app based on the value of Choice/ Optionset field.

I am going to bind this table to a Gallery inside canvas app where I need to show all Device orders in Pending Approval status.

I use the below formula for the Items property of the gallery.

Filter a datasource in Canvas app based on the value of Choice/ Optionset field.

This is how you would write if you need to filter using Choice field. However it’s not the case here. As you can see, the formula is throwing an error.

The trick here is treat Order status field as a control and then consider ‘Pending Approval’ as one of the values for the specified control. But how do I do this? Well, below is the formula to do the same.

Filter a datasource in Canvas app based on the value of Choice/ Optionset field.

We need to use Order Status with @ symbol to signify it as the data source. It is in the below format.

[@'Choice field']

Hope this helped!

You might also like the below posts.

Debajit Dutta
Business Solutions MVP