cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Surender
Frequent Visitor

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
Frequent Visitor

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 Continued Contributor
Continued Contributor

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
Frequent Visitor

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 Continued Contributor
Continued Contributor

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
Frequent Visitor

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 Continued Contributor
Continued Contributor

Re: Filter records with multi select option set values

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

Community Support
Community Support

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
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Top Solution Authors
Top Kudoed Authors
Users online (6,266)