Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
The code below works, but I hear using nested IF's is not the most elegant way to go. I am not a programmer, so I need a bit of advice. Is there a better way to achieve what I am doing, or is it simple enough to keep it as is? I would have used SWITCH, but i have to run a logical test against two columns in two of those IF statements, and I don't believe SWITCH handles that.
Milestone Saturation = IF(Tasks[Milestones Lead (Days)] > 0 && Tasks[TaskPercentCompleted] = 100,"Complete", IF(Tasks[Milestones Lead (Days)] > 0 && Tasks[TaskPercentCompleted] = 0,"Late", IF(Tasks[Milestones Lead (Days)] = 0, "Current", IF(Tasks[Milestones Lead (Days)] < 0 && Tasks[Milestones Lead (Days)] >= - 3, "Upcoming", IF(Tasks[Milestones Lead (Days)] < -3, "Future" )))))
Thanks!
Solved! Go to Solution.
try this:
Milestone Saturation = SWITCH( TRUE(), [Milestones Lead (Days)] > 0, SWITCH( TRUE(), [TaskPercentCompleted] = 100, "Complete", [TaskPercentCompleted] = 0, "Late" ), [Milestones Lead (Days)] = 0, "Current", [Milestones Lead (Days)] < 0, SWITCH( TRUE(), Tasks[Milestones Lead (Days)] >= - 3, "Upcoming", Tasks[Milestones Lead (Days)] < -3, "Future" ) )
try this:
Milestone Saturation = SWITCH( TRUE(), [Milestones Lead (Days)] > 0, SWITCH( TRUE(), [TaskPercentCompleted] = 100, "Complete", [TaskPercentCompleted] = 0, "Late" ), [Milestones Lead (Days)] = 0, "Current", [Milestones Lead (Days)] < 0, SWITCH( TRUE(), Tasks[Milestones Lead (Days)] >= - 3, "Upcoming", Tasks[Milestones Lead (Days)] < -3, "Future" ) )
Looks good! Thank you! I am assuming that this is a more efficient way, and that this can be called a "Nested Switch" 🙂
You could call it that.
I should have given credit to the idea in my first reply that it was from a posting I recalled seeing from Rob Collie - https://powerpivotpro.com/2015/03/the-diabolical-genius-of-switch-true/
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
81 | |
76 | |
61 | |
37 | |
33 |
User | Count |
---|---|
101 | |
56 | |
51 | |
45 | |
40 |