cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
StephenM
Advocate II
Advocate II

Help needed with multiple filters

hi - i need some help with using multiple filters please.

 

I want to use 3 filters - Priority, Comapny and Status to filter the data shown on the page.

 

3 filters.JPG

Priorty Filter field is called dropdown1 and contains ALL, Critical, Important, Normal, Unimportant as choices

Company Filter field is called dropdown 2 and similarly has ALL plus several options

Status fielter field is called, unsurprisingly, dropdown 3 and has the same ALL plus options set up

 

'IT Projects' is the source (Sharepoint List). Using just the first filter only i have this code that works fine....

 

Browsegallery1.items = If(Dropdown1.Selected.Value="All",'IT Projects',Filter('IT Projects',Priority.Value=Dropdown1.Selected.Value))

 

But i cant get my head around how to add a 2nd and 3rd look up. I started trying nested IFs but just got myself tied up in knots and confused.

 

Hope someone can help.

 

many thanks

Stephen

1 ACCEPTED SOLUTION

Accepted Solutions

thank you - that worked a treat.  i really appreciate your help.

View solution in original post

3 REPLIES 3
strategery
Resolver II
Resolver II

"If" can be used in-line to generate filter expressions, and the "Filter" function can contain multiple filter expressions, just separate them with commas. Instead of starting with "If", start with "Filter" and use several ifs to create the filter expressions. I think this is what you want:

 

Browsegallery1.Items = Filter('IT Projects',

If(Dropdown1.Selected.Value="All",Priority.Value<>"",Priority.Value=Dropdown1.Selected.Value),

If(Dropdown2.Selected.Value="All",Company.Value<>"",Company.Value=Dropdown2.Selected.Value),

If(Dropdown3.Selected.Value="All",Status.Value<>"",Status.Value=Dropdown3.Selected.Value))

 

Each if statement here says if the value is "All", just return all records where the value isn't blank, otherwise return values that match the dropdown.

 

Anonymous
Not applicable

Hi.

 

Tip: You can add If() statements inside conditions of the Filter function.

Like this:

 

Filter( 'IT Projects',
    If( PriorityDropdown.Selected.Value = "All", true, 
        PriorityValue = PriorityDropdown.Selected.Value ),
    If( CompanyDropdown.Selected.Value = "All", true,
        CompanyValue = CompanyDropdown.Selected.Value ),
    If( StatusDropdown.Selected.Value = "All", true,
        StatusValue = StatusDropdown.Selected.Value )
)

I assumed names for the dropdowns and fields. Change names as necessary.

Also, the Filter() function can have more than 2 arguments. In the code above, it has 4. The last 2 are just additional conditions. And all conditions (arguments 2 - 4) are basically joined by AND operators (i.e. Condition1 AND Condition2 AND Condition3).

 

Let me know if it works. 

 

thank you - that worked a treat.  i really appreciate your help.

View solution in original post

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

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

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