Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
malqinneh
Regular Visitor

DAX Measure with Nested IF Statements

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,

1 ACCEPTED 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



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

4 REPLIES 4
malqinneh
Regular Visitor

Thank you!

TheOckieMofo
Resolver II
Resolver II

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



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors