web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Stacking Filters on a ...
Power Apps
Answered

Stacking Filters on a SharePoint List

(0) ShareShare
ReportReport
Posted on by 17

I've been looking around for a solution to this but can't seem to find anything.  I'm trying to filter a SharePoint List with a combo box (which allows multiple selections) to apply multiple filters at a time to the data source.  This is how it is currently set up and it works fine, however, each filter I apply overwrites the next due to the OR condition. 

 

Any thoughts on how I might alter the code to allow for the filters to be stacked?

 

Filter(
[@'SP List'],
IsBlank(cboFilter.SelectedItems.Value) Or IsEmpty(cboFilter.SelectedItems) Or
If(cboFilter.Selected.Value="My Advisories",'Modified By'.DisplayName=Office365Users.MyProfile().DisplayName) Or
If(cboFilter.Selected.Value="Approval Pending",ApprovalStatus="Pending") Or
If(cboFilter.Selected.Value="Not Sent",!EmailSent) Or
If(cboFilter.Selected.Value="Active Items",IsActive)
)
 
Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,989 Moderator on at

    @nodonnell 
    I think the IF statement can be removed...

     

    Filter(
     [@'SP List'],
     IsBlank(cboFilter.SelectedItems.Value)=Blank Or IsEmpty(cboFilter.SelectedItems) Or
     (cboFilter.Selected.Value="My Advisories" And 'Modified By'.DisplayName=Office365Users.MyProfile().DisplayName) Or
     (cboFilter.Selected.Value="Approval Pending" And ApprovalStatus="Pending") Or
     (cboFilter.Selected.Value="Not Sent" And !EmailSent) Or
     (cboFilter.Selected.Value="Active Items" And IsActive)
    )

     

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • nodonnell Profile Picture
    17 on at

    Thanks for the suggestion, @mdevaney.  I gave it a try but I still don't get the stacking effect that I'm looking for.  For example, if I want to see unsent items that are active, I should be able to apply both the "active items" filter and also the "not sent" filter.  Currently, whichever filter is applied last is taking precedence so if I apply "active items" it filters properly but when I then add the "not sent" filter as well, the filtered data shows unsent items but it includes ALL unsent items, instead of just active unsent items.  I hope that makes sense.

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    Try removing the Or statements and write it like this:

     

    Filter(

    [@'SP List'],

    IsBlank(cboFilter.SelectedItems.Value Or IsEmpty(cboFilter.SelectedItems), Filter statement,

    cboFilter.Selected.Value = "My Advisories" And 'Modified By'.DisplayName = Office365Users.MyProfileV2().DisplayName, Filter Statement,

    cboFilter.Selected.Value = "Approval Pending" And ApprovalStatus = "Pending", FilterStatement,

    cboFilter.Selected.Value = "Not Sent" And !EmailSent, Filter Statement,

    cboFilter.Selected.Value = "Active Items" And IsActive, Filter Statement

     

    )

     

    This will cause your filter to evaluate each set of conditions and apply the correct filtering when it finds the statement that matches.  You will have to add some sort of filter to the end of each of these for it to work correctly.   Here is an image from one of my apps to give you an idea.

     

    Filter.png

     

  • Verified answer
    nodonnell Profile Picture
    17 on at

    Thanks for the suggestion @JR-BejeweledOne.  Unfortunately, it didn't work out the way I was envisioning it.  After lots more trial and error, I discovered that what I really needed was nested Filter() functions.  In the end, this was going to be too complex for my novice skills, so I redesigned my filter.  I broke out the IsActive filter into its own separate toggle-controlled filter and then removed the multi-select capabilities of the combo box for the 3 other filters to reduce the complexity.  I then nested a Filter() function inside another to allow additional filters to be applied to active items only.  I also adjusted the code to avoid delegation issues (including the dreaded Boolean issue with SharePoint).  In the end, this is what I ended up with, which seems to work well:

     
    If(
    IsBlank(varFilter) And boolActiveRecords,
    Filter(
    [@'IT Advisory List'],
    IsActive = "Yes"
    ),
    boolActiveRecords,
    Filter(
    Filter(
    [@'IT Advisory List'],
    Or(
    varFilter = "My Advisories" And 'Modified By'.DisplayName = varUserName,
    varFilter = "Pending Approval" And ApprovalStatus = "Pending",
    varFilter = "Not Sent" And ApprovalStatus = "Approved" And EmailSent = false
    ) ),
    IsActive = "Yes"
    ),
    !boolActiveRecords,
    Filter(
    [@'IT Advisory List'],
    IsActive = "No"
    ) )

     

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    Glad you figured it out.   This is the best part of this community.  You take what people give you and use it to figure out your own solutions and learn a whole lot in the process.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard