If('Active User Toggle'.Value,
Filter(
Sort('Project Portfolio - Project Input', Title), //just sorting the output
'Project Lead'.Email = User().Email), //filter for the active user toggle (doesn't like)
If(
'Active Projects Toggle'.Value,
Filter(
Sort('Project Portfolio - Project Input', Title), //just sorting the output
'Project Status'.Value = "Active"), //filter for the active project toggle
Sort('Project Portfolio - Project Input', Title)))
Solved! Go to Solution.
For a little more manageable formula, you might want to also consider:
Sort(
Filter('Project Portfolio - Project Input',
If('Active User Toggle'.Value, 'Project Lead'.Email = User().Email, true) &&
If('Active Projects Toggle'.Value, 'Project Status'.Value = "Active", true)
),
Title
)
It's not always a great thing to have multiple filters in a formula - if you decide you need to change the filter criteria, or add more, if you have multiple filters, you will need to change all of them. When you simplify (I like to call it refactoring) you get to one filter statement that is easy to add to or change if needed.
Hi @enswitzer,
Do you need to apply both toggle filters at the same time? At the moment you will only applying your Project Status filter if the 'Active User Toggle' is false.
Try building out each case in the If statement:
If(
!'Active User Toggle'.Value && !'Active Projects Toggle'.Value,
Sort('Project Portfolio - Project Input', Title),
'Active User Toggle'.Value && !'Active Projects Toggle'.Value,
Filter(
Sort('Project Portfolio - Project Input', Title),
'Project Lead'.Email = User().Email
),
!Active User Toggle'.Value && 'Active Projects Toggle'.Value,
Filter(
Sort('Project Portfolio - Project Input', Title),
'Project Status'.Value = "Active"
),
Filter(
Sort('Project Portfolio - Project Input', Title),
'Project Status'.Value = "Active" && 'Project Lead'.Email = User().Email
)
)
Hope that helps!
Joel
For a little more manageable formula, you might want to also consider:
Sort(
Filter('Project Portfolio - Project Input',
If('Active User Toggle'.Value, 'Project Lead'.Email = User().Email, true) &&
If('Active Projects Toggle'.Value, 'Project Status'.Value = "Active", true)
),
Title
)
It's not always a great thing to have multiple filters in a formula - if you decide you need to change the filter criteria, or add more, if you have multiple filters, you will need to change all of them. When you simplify (I like to call it refactoring) you get to one filter statement that is easy to add to or change if needed.
Just an observation, but while the formula is more manageable, won't placing the IFs inside the filter make this non-delegable?
In this specific case, that may not be an issue and the User().Email predicate may be making this non-delegable already, but that could be solved by assigning User().Email to a variable and referencing that.
The use of a choice field:
'Project Status'.Value = "Active"
is possibly another cause of non-delegation - I avoid Choice Fields (and SharePoint!) so don't know if that is something that has been improved in recent updates.
Yes - it was purely conceptual. If delegation is an issue, then it would be written differently. And yes, the User function would typically be put outside of the filter.
Delegation on complex columns is not so much a concern any longer as they can now delegate those queries.
Incidentally, if I was concerned over delegation issues, I would rewrite to this formula:
With({lclUser: User().Email},
Sort(
Filter('Project Portfolio - Project Input',
('Active User Toggle'.Value || 'Project Lead'.Email = lclUser) &&
('Active Projects Toggle'.Value || 'Project Status'.Value = "Active")
),
Title
)
)
Oddly enough, it is kind of the same filter criteria, but PowerApps can't parse the If statements into this to be delegable...maybe one day it will.
Thanks for commenting!
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
195 | |
67 | |
46 | |
41 | |
28 |
User | Count |
---|---|
255 | |
119 | |
86 | |
84 | |
83 |