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

Filter Gallery using multiple conditions

Hello All, I hoping some genius out there can help me. I am trying to use multiple dropdowns, a toggle and a checkbox to filter a SPO list using a gallery.

 

I have a two SPO lists. 1. Audits 2. Audit Tasks.

I created two Galleries: 1. Gallery_AllAudits 2. Gallery_Tasklist_1.

Gallery_Tasklist_1 filters from the SPO Audit Tasks based upon Gallery_AllAudit item selected. 

I have multiple dropdowns (above the Gallery_Tasklist_1) that I want to use to filter the Gallery_Tasklist_1 specific to the selected Audit. 

Dropdowns.png

I'm having several issues.

1. How can I filter the gallery based the dropdowns independtly, the way it's setup now, it doesn't filter the list.

Inp_AuditName_1 Default: Gallery_AllAudits.Selected.Audit_Name

2. How can I add a filter based upon a toggle (SPO yes/no field) nor the Checkbox (SPO yes/no field).

 

 

This is the syntax I current have for Gallery_TaskList_1:

 

Filter('Audit Tasks',If(IsBlank(Inp_AuditName_1.Text),true,Audit_Name=Inp_AuditName_1.Text)&&
If(IsBlank(Dropdown_Req.Selected.Result),true,Req_x002e__x0023_=Dropdown_Req.Selected.Result)&&
If(IsBlank(Dropdown_Ref.Selected.Result),true,Ref_x002e_ID=Dropdown_Ref.Selected.Result)&&
If(IsBlank(Dropdown_ARequest.Selected.Result),true,Comment=Dropdown_ARequest.Selected.Result)
||If(Dropdown_ARequest.Selected.Result="-",Comment<>(Dropdown_ARequest.Selected.Result),"")
)

1 REPLY 1
iAm_ManCat
Super User II
Super User II

Hello!

 

Ok, so you want multiple options to filter by and for them all to be applied individually - there are two main ways to go about this:

As a starter, either:

1. Include an "ALL" item into your dropdowns by adding it as the first item when collecting the items, for example:

 

ClearCollect(
                     ProfitCentresSubList,
                     //Here we are adding a single record
                     //Whose value for all filterable columns is "ALL"
                     {
                          'Profit Centre Name': "ALL",
                           ClosedStatusText:"ALL",
                           ProfitCentre:"ALL",
                           ApprovalStatusText:"ALL"
                     },
                     SortByColumns(
                                                ProfitCentres,
                                                "ProfitCentreFullText",
                                                Ascending
                     )
);

or

 

2. Do multiple top-level 'If' statements (always top-level to prevent delegation issues) - I do not recommend this option, as you will have to provide an 'If' case for all possible options, which becmes hard to debug

 

So carrying on from Choice 1.

 

You would then set on the Gallery_Tasklist_1 Items = something like:

 

Filter(
          'Audit Tasks',
          (
          //Here they have selected All, so we are checking if they did and not filtering
          Inp_AuditName_1.Text = "ALL"
          //Otherwise, filter by what they chose
             ||
          Audit_Name = Inp_AuditName_1.Text
          )
          &&
          (
           Dropdown_Req.Selected.Result = "ALL"
              ||
           Req_x002e__x0023_= Dropdown_Req.Selected.Result
          )
          &&
          (
          Dropdown_Ref.Selected.Result = "ALL"
             ||
          Ref_x002e_ID = Dropdown_Ref.Selected.Result 
          )
          &&
          (
          Dropdown_ARequest.Selected.Result ="ALL"
             ||
          Comment = Dropdown_ARequest.Selected.Result
          )
&&
SPOtoggleColumnName = Toggle1
&&
SPOCheckBoxColumn = Checkbox1 )

 

 

The Toggle and Checkbox items act as boolean variables themselves, so you can filter by:

BooleanColumnName = ToggleName

or

BooleanColumnName = CheckboxName

 

 

Please give this a try and feel free to reply here if you have any questions, I'll try get back to you as soon as I can (but I also have my day-to-day work to attend to) 🙂

 

Cheers,

ManCat

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (1,958)