Skip to main content
Community site session details

Community site session details

Session Id : WRyeHHLtt2II7qZhx5QxOC
Power Apps - Building Power Apps
Answered

If statement inside filter condition

Like (0) ShareShare
ReportReport
Posted on 17 Mar 2020 19:34:38 by 3

Hello!

 

  I'm trying to have an if statement inside a filter statement, and keep getting delegation warnings. I'm wondering if anyone can point me in the right direction!

 

Filter(MyTable,If(DropDown.Selected.Value = "All",true,MyTableColumn = DropDown.Selected.Value))

 

Anyone know how to get this right? Has to not have delegation issues! Also, I know that I could do the If statement outside the filter, but in my actual project there are many dropdowns all needing this same treatment, so I end up with this huge branching logic formula - which I'm trying to avoid. Thanks!

Categories:
  • nmasmo Profile Picture
    91 on 19 Oct 2023 at 14:50:53
    Re: If statement inside filter condition

    @mdevaney  Great solution, thank you.

  • Community Power Platform Member Profile Picture
    on 14 Dec 2022 at 06:42:25
    Re: If statement inside filter condition

    How to if condition two filter its possible?

  • Community Power Platform Member Profile Picture
    on 15 Nov 2022 at 13:44:12
    Re: If statement inside filter condition

    Hello,

    I've a system with multiple conditions... if I follow your solution, I've the next awful result:

     

    if(condition,
     filter,
     if(condition,
     filter,
     if(condition,
     filter,
     if(condition,
     filter,
     table
     )
     )
     )
    )

     

     

    My use case is a bit special because I use a sharepoint with 3 dropdown and 1checkbox, ticked I want show only elements with true value else all elements.

    For the 3 dropdown, I want filter the items together if each of them has a value, like being able to filter if there is only 1 that has a value. If none has a value then the filter doesn't apply and return the table filtered by the checkbox or no:

     

     

    I've an example of my list with 3 fake tasks:

    [{

        "Title": "one",

        "Category": "A",

        "ShowInTheMeeting": false,

        "Status": "Closed",

        "Assign to":UserObj

    },

    {

        "Title": "two",

        "Category": "B",

        "ShowInTheMeeting": false,

        "Status": "Pending",

        "Assign to":UserObj

    },

    {

        "Title": "three",

        "Category": "A",

        "ShowInTheMeeting": true,

        "Status": "Opened",

        "Assign to":UserObj

    }].

     

     

    That's why I think a filter with a conditionnal value is necessary, because you didn't to repeat your code, or a possibility to create a function on the page without "cheating" with the components to compensate the lack of possibilities

  • Pstork1 Profile Picture
    67,129 Most Valuable Professional on 15 Nov 2022 at 13:03:22
    Re: If statement inside filter condition

    Since you can accomplish the same thing by using the If() on the outside I doubt you will see that change.

  • Community Power Platform Member Profile Picture
    on 15 Nov 2022 at 12:45:58
    Re: If statement inside filter condition

    2 years later we don't have any possibility to use the if statement inside filter objects
    ----------------

    Example:

     

    Filter( MyColors,

    If(dropdownColor.Value = "red", color.Value = "red")

    )

  • nikhil17_92 Profile Picture
    6 on 30 Dec 2021 at 10:17:36
    Re: If statement inside filter condition

    Thanks a lot! Helped me reduce a long code with if conditions to an optimized short code.

  • Kiki1 Profile Picture
    30 on 16 Sep 2021 at 01:52:53
    Re: If statement inside filter condition

    A year later this helped me. Thanks 

  • Pstork1 Profile Picture
    67,129 Most Valuable Professional on 17 Mar 2020 at 19:38:29
    Re: If statement inside filter condition

    Unfortunately, embedded IF() statements don't really work inside a Filter.  You can create an IF() that executes different Filters based on a condition though.  What you want is this

    IF(DropDown.Selected.Value = "All",MyTable,Filter(MyTable,MyTableColumn = DropDown.Selected.Value))
  • Verified answer
    mdevaney Profile Picture
    29,987 Moderator on 17 Mar 2020 at 19:38:20
    Re: If statement inside filter condition

    @JoeCochran 

    A quick re-write of this formula will do the trick!

    Filter(
     MyTable, 
     DropDown.Selected.Value = "All"
     Or MyTableColumn = DropDown.Selected.Value
    )

     

    ---
    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." 

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2

Loading complete