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

If statement inside filter condition

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

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

View solution in original post

2 REPLIES 2
Highlighted
Super User III
Super User III

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

View solution in original post

Highlighted
Dual Super User III
Dual Super User III

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))


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,768)