cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Surender
Level: Powered On

Filter records with multi select option set values

I have an entity(User Bookings)) in CDS and created a field(Service Type) of type Multi Select Optionset with values "Appointment", "Phone Call", "F2F"

 

And then now Imported some records to the entity with Multi select Optionset field data populated.

 

Now in Canvas App I want to load Gallery with only records where Service Type in ("Appointment", "Phone Call")

 

Could you help me how to filter records based on multi select optionset field data.

 

Thanks

 

Surender

1 ACCEPTED SOLUTION

Accepted Solutions
Surender
Level: Powered On

Re: Filter records with multi select option set values

Hi @jhall 

 

Here is my requirement and what I have,

 

I have an entity "User Bookings" and in that entity I have various fields and one of them is Multi select optionset named "Service Type" which got values "Appointment", "Phone Call" and "F2F".

 

I want to fill gallery with all User Bookings records where Service type eq "Appointment" or "Phone Call".

 

The query you posed helped me some where and at last understood the logic around the query and here is the final query that works.

 

ClearCollect(MyCol, Filter('User Bookings', CountRows(Filter('Service Type', Value = [@'Service Type'].Appointment Or Value = [@'Service Type'].'Phone Call'))>0))

 

Many Thanks

 

Surender

View solution in original post

6 REPLIES 6
jhall
Level 8

Re: Filter records with multi select option set values

Something similar to:

  • Filter(myGallery, Or("Appointment" in ServiceType,"Phone Call" in ServiceType))

But you'd probably want to make this dynamic based on items you're selecting for the Filter (e.g. de-select "Appointment", select "F2F", etc.).

Also, depending upon the size of your list you're sorting through, you might want to do a pre-filter before you're even populating whatever is filling your Gallery (myGallery in my example above).

Surender
Level: Powered On

Re: Filter records with multi select option set values

Hi @jhall ,

 

Thanks for your reply.

 

I have updated my query now like this:

ClearCollect(MyCol, Filter('User Bookings',Or([@'Service Type'].Appointment in 'Service Type'.Value, [@'Service Type'].'Phone Call' in 'Service Type'.Value)))

 

It is not erroring but not displaying anything. I have tried 'Service Type' after in operator as well. Any idea of what am I missing?

 

Thanks

 

Surender

jhall
Level 8

Re: Filter records with multi select option set values


@Surender wrote:

ClearCollect(MyCol, Filter('User Bookings',Or([@'Service Type'].Appointment in 'Service Type'.Value, [@'Service Type'].'Phone Call' in 'Service Type'.Value)))

 


Thaaaat doesn't look right.  I think you've got those reversed, but let me clarify.  What control contains the items you're selecting to search for and what is the name of your data source? 

I am assuming you're doing a search where the user selects criteria X and then you filter the list to only show items where X is true.  Without the names of your controls and data source I'm not sure if you've got this written out correctly.

Surender
Level: Powered On

Re: Filter records with multi select option set values

Hi @jhall 

 

Here is my requirement and what I have,

 

I have an entity "User Bookings" and in that entity I have various fields and one of them is Multi select optionset named "Service Type" which got values "Appointment", "Phone Call" and "F2F".

 

I want to fill gallery with all User Bookings records where Service type eq "Appointment" or "Phone Call".

 

The query you posed helped me some where and at last understood the logic around the query and here is the final query that works.

 

ClearCollect(MyCol, Filter('User Bookings', CountRows(Filter('Service Type', Value = [@'Service Type'].Appointment Or Value = [@'Service Type'].'Phone Call'))>0))

 

Many Thanks

 

Surender

View solution in original post

jhall
Level 8

Re: Filter records with multi select option set values

Well, glad I sorta-helped.  Good luck!  Smiley LOL

Community Support Team
Community Support Team

Re: Filter records with multi select option set values

Hi @Surender ,

Have you solved your problem?

 

I agree with yout thought almost. If you have solved your problem, please go ahead to click "Accept as Solution" to identify this thread has beed solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 236 members 5,481 guests
Please welcome our newest community members: