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!
How to if condition two filter its possible?
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
Since you can accomplish the same thing by using the If() on the outside I doubt you will see that change.
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")
)
Thanks a lot! Helped me reduce a long code with if conditions to an optimized short code.
A year later this helped me. Thanks
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))
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."
WarrenBelz
146,645
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,997
Most Valuable Professional