cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
colonel_claypoo Helper III
Helper III

Filter array action to filter on choice field with checkboxes (allow multiple selections)?

Hello,

 

is it possible to for the filter array action to filter on a choice field that uses checkboxes (allow multiple selections)?

So far I can't get it to work, only if the choice field type is 'Drop-Down Menu'.

Here's the error message:

 

2.png

 

And here's the action:

 

1.png

 

I want to check if the type field is equal to the value of 'News' for a choice field with checkboxes (allow multiple selections).

 

Thanks for your help.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Filter array action to filter on choice field with checkboxes (allow multiple selections)?

11 REPLIES 11
Super User
Super User

Re: Filter array action to filter on choice field with checkboxes (allow multiple selections)?

Have you tried using contains rather than equals?

JamesReames
New Member

Re: Filter array action to filter on choice field with checkboxes (allow multiple selections)?

This is a fun one!

 

So checkboxes give their Selected Value, not as a single value, but as an array.

 

What this means in pseudo: [Value] looks more like ['News':true], ['Option 2: false], [option 3: false], [option 4: false]

 

You may be able to do an "Apply to Each" on the Checkbox. . And inside of that apply to each check if the items('Apply_to_each')?['Value'] equals 'News'

 

2018-11-26_10-44-36.png

colonel_claypoo Helper III
Helper III

Re: Filter array action to filter on choice field with checkboxes (allow multiple selections)?

Yes, same error, unfortunately.

 

chrome_2018-11-27_07-09-40.png

colonel_claypoo Helper III
Helper III

Re: Filter array action to filter on choice field with checkboxes (allow multiple selections)?

[deleted, duplicate post]

colonel_claypoo Helper III
Helper III

Re: Filter array action to filter on choice field with checkboxes (allow multiple selections)?


@JamesReames wrote:

This is a fun one!

 

So checkboxes give their Selected Value, not as a single value, but as an array.

 

What this means in pseudo: [Value] looks more like ['News':true], ['Option 2: false], [option 3: false], [option 4: false]

 

You may be able to do an "Apply to Each" on the Checkbox. . And inside of that apply to each check if the items('Apply_to_each')?['Value'] equals 'News'

 

2018-11-26_10-44-36.png



Thanks. I'm trying to comprehend. How would I be able to run the "Apply to each" on the checkboxes only? Currently, the filter action acts upon 
body('GetRegisteredUsers')?['value'] which is a SharePoint list in which "Type" is a column that contains the options "News" and "Alerts".

Super User
Super User

Re: Filter array action to filter on choice field with checkboxes (allow multiple selections)?

colonel_claypoo Helper III
Helper III

Re: Filter array action to filter on choice field with checkboxes (allow multiple selections)?

Hi Pieter,

very cool. I've been following your blog for a while now. Always good stuff.

 

I'm playing around with this but I'm stuck at the very last step where you described using a switch inside the apply to each loop. My first though was why not use a condition.

In my case I don't need to perform a different action for each choice und rather check if a vertain choice is matched.

Therefore, I wanted to try using a condition instead of a switch. To my astonishment the condition always evaluates to false:

 

chrome_2018-11-28_12-54-46.png

 

Execution result:

 

chrome_2018-11-28_12-58-00.png

 

I also tried wrapping the 1 in quotes but to no avail.

Any idea why the condition always evaluates to false?

 

Thanks!

Super User
Super User

Re: Filter array action to filter on choice field with checkboxes (allow multiple selections)?

I'm not sure.

 

I just tried this:

 

worked.PNG

 

And it worked as expected. Could it be thast you choice options have an 'invisible' space?

 

Maybe check in SharePoint the field values. Or otherwise use a Trim(...) function to clear the spaces if there are any.

 

colonel_claypoo Helper III
Helper III

Re: Filter array action to filter on choice field with checkboxes (allow multiple selections)?

I've just experimented further. It seems that as soon as the multi-value checkbox field contains only numbers it doesn't work. When I copy your terms, i.e. Choice 1, Choice 2, Choice 3 it works. But by using only 1,2,3 the condition always evaluates to false. Can you confirm? Should just be a quick change on your side. Thanks.

Super User
Super User

Re: Filter array action to filter on choice field with checkboxes (allow multiple selections)?

I got the same.

 

In you condition can you replace

 

1

 

with 

 

string(1)
 
Using the string expression you will force Flow to make a string comparison rather than a number comparison.
colonel_claypoo Helper III
Helper III

Re: Filter array action to filter on choice field with checkboxes (allow multiple selections)?

That seems to be it! This works. More confirmation that only string comparisons work in this scenario is that even for the Switch in the Case the number 1 has to be wrapped in quotes in order for it to work.

 

chrome_2018-11-28_15-41-10.png

 

Thanks a lot for confirming, you've been extremely helpful.

Helpful resources

Announcements
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 Automate Community!

firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Users online (8,316)