Forum Discussion

malqinneh's avatar
malqinneh
Regular Visitor
9 years ago
Solved

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,

  • 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

4 Replies

    • malqinneh's avatar
      malqinneh
      Regular Visitor

      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? 

      • TomMartens's avatar
        TomMartens
        Super User

        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