cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Filter gallery through checkboxes

Hi there,

 

I have an issue with a gallery in PowerApps. The gallery displays items filtered from a SharePoint list column calles "Current Approval Status". At the moment the gallery displays the list items of three (out of seven) of the possible status values. 

 

The code I am using to do this is:

 

Sort(Filter('IT Project Approval Request';'Current Approval Status'.Value="Approved by IT Manager" Or
'Current Approval Status'.Value="Ready for examination" Or 'Current Approval Status'.Value="Ready for final decision");ID;Descending

 

I now want to filter the gallery by using three different checkoxes, displaying the different approval status possibilities.

So one Checkbox sorts by "Approved by IT Manager", the other by "Ready for examination" etc. and if two checkboxes are selected the respective items should be displayed.

 

Does anyone have an idea how to do that?

 

Dorothee

11 REPLIES 11
WarrenBelz
Super User
Super User

Hi @Anonymous ,

Using Approved, Examination and Decision as the names of your check boxes (change to your names) try this.

Sort(
   Filter(
      'IT Project Approval Request';
      If(
         Approved.Value=true;
         'Current Approval Status'.Value="Approved by IT Manager" &&
         Examination.Value=true;
         'Current Approval Status'.Value="Ready for examination" &&
         Decision.Value= true;
        'Current Approval Status'.Value="Ready for final decision"
      )
   );
   ID;
   Descending
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Anonymous
Not applicable

@WarrenBelz Thank you. 

 

How can I add that, if none of the boxes are selected I want to show all items with either of the three statuses?

 

(Like in my code -> 'IT Project Approval Request';'Current Approval Status'.Value="Approved by IT Manager" Or
'Current Approval Status'.Value="Ready for examination" Or 'Current Approval Status'.Value="Ready for final decision")

 

 

Ok @Anonymous ,

I provided a solution for your query - you did not mention this aspect. Your additional requirements could be met with something like - note I am trying to provide suggested structure - you may have to clean up the commas & brackets etc.

Sort(
   If(
      Approved.Value=false && Examination.Value=false && Decision.Value= false;
      'IT Project Approval Request';
       Filter(
         If(
            'IT Project Approval Request';
            Approved.Value=true;
            'Current Approval Status'.Value="Approved by IT Manager" &&
            Examination.Value=true;
            'Current Approval Status'.Value="Ready for examination" &&
            Decision.Value= true;
           'Current Approval Status'.Value="Ready for final decision"
         )
      )
   );
   ID;
   Descending
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Anonymous
Not applicable

@WarrenBelz Thanks, Warren. One more question: When I want to select 2 out of three checkboxes and filter the results in my gallery accordingly, how should I modify my code?

Hi @Anonymous ,
I used an && (and) separator - it should work in the current format.

Please let me know if it does not produce the results you want

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Anonymous
Not applicable

@WarrenBelz Unfortunately it doesn't. One I select multiple checkboxes, the gallery doesn't display any items at all.

 

I am using the following formula:


Filter(
'Datasource';
If(
Checkbox_1Value=true;
'Current Approval Status'.Value="Approved by IT Manager" &&
Checkbox_2.Value=true;
'Current Approval Status'.Value="Ready for examination" &&
Checkbox_3.Value=true;
'Current Approval Status'.Value="Ready for final decision";
'Current Approval Status'.Value="Approved by IT Manager" Or
'Current Approval Status'.Value="Ready for examination" Or
'Current Approval Status'.Value="Ready for final decision")
)

OK @Anonymous ,

I have a working solution that surprised me a bit. however if it is below - same principle as yours

ThreeBoxFilter.gif

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Code is as follows

 

 

If(
   !Approved.Value && !Examination.Value && !Decision.Value;
   'IT Project Approval Request';
   Filter(
      'IT Project Approval Request';
      If(
          Approved.Value;
          'Current Approval Status'.Value="Approved by IT Manager"
      ) ||
      If(
         Examination.Value;
         'Current Approval Status'.Value="Ready for examination"
      ) ||
      If(
         Decision.Value;
         'Current Approval Status'.Value="Ready for final decision"
      )
   )
)

you can add the Sort.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Anonymous
Not applicable

This is the code I ended up with after working through the examples you gave, thank you.  Even though I am comparing two string values I am getting a delegation warning.  I was hoping filtering with string type data would have avoided that. 

 

If(
chkBox1.Value=false && chkBox2.Value=false && chkBox3.Value=false,
'Sharepoint List Name',
Filter(
'Sharepoint List Name',
If(
chkBox1.Value=true,
ListColumn="ListColumnValue1"
) ||
If(
chkBox2.Value=true,
ListColumn="ListColumnValue2"
) ||
If(
chkBox3.Value= true,
ListColumn="ListColumnValue3"
)
)
)

lcraig09
New Member

Hi, I got this code in my app, it works when using the ALT key and clicking on the boxes. But when I run the app it displays nothing in my list.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,055)