Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi,
I'm wondering how I can create a nested if statement on DAX to return a value. If my date falls between A and B, Return Week1, OR if it falls between A and B, Return Week 2... and so on.
Thank you,
Solved! Go to Solution.
Hey,
so it looks similar, but the DAX parser / engine sometimes is not that smart, for this reason use
AND(Issues[Created Date]>= DATE(2017,7,21) ...
instead
Regards
Thank you!
You're probably best off using the SWITCH function instead of multiple nest ifs. They will both get you to the promised land, but the SWITCH function is a little cleaner and easier to keep straight.
Here's a couple of blog posts about SWITCH:
https://powerpivotpro.com/2012/06/dax-making-the-case-for-switch/
https://powerpivotpro.com/2015/03/the-diabolical-genius-of-switch-true/
Get to know SWITCH. It's definitely a function I use frequently.
Thanks so much, this is very helpful! One of the examples provided is almost an identical problem. I had an add-on question that I thought I can append here:
My formula so far is:
Week Opened = SWITCH(TRUE(),
AND(Issues[Created Date]>= 7/21/2017, Issues[Created Date])<= 7/30/2017, "Week 1",
AND(Issues[Created Date]>= 7/31/2017, Issues[Created Date])<= 8/6/2017, "Week 2", "Other")
However, I'm receiving a "DAX comparison operations do not support comparing values of type True/False with values of type Number. Consider using the VALUE or FORMAT function to convert one of the values." error. The [Created Date] column is in fact a date and in the same format. Can you help identify what issue may be?
Hey,
so it looks similar, but the DAX parser / engine sometimes is not that smart, for this reason use
AND(Issues[Created Date]>= DATE(2017,7,21) ...
instead
Regards
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 98 | |
| 72 | |
| 50 | |
| 50 | |
| 43 |