Forum Discussion

Cramos's avatar
Cramos
Frequent Visitor
9 years ago
Solved

IF function when Date is empty

Hi, 

 

I have 3 columns with different dates. I need a function that:

 

IF Column Date1 is empty, take Column Date2, and if this one is empty, take Column Date3.

 

If i use Column(Date1)="", it says DAX comparison cant compare Date with Text, the same happen when I use 0 or null.

 

 

P.D: Maybe this have been answer before, but I couldn't find it. Sorry in advance

 

Thank you!!

  • Cramos

     

    Try using this Dax:

     

    NewDate =
    IF (
        Table1[Date1] = BLANK (),
        IF ( Table1[Date2] = BLANK (), Table1[Date3], Table1[Date2] );
        Table1[Date1]
    )

     

     

     

     

11 Replies

    • Cramos's avatar
      Cramos
      Frequent Visitor

      I get "Expressions that yield variant data-type cannot be used to define calculated columns", not sure how to formulate,

       

      IF(ColumnDate=Blank()...?

       

      Thanks

      • Vvelarde's avatar
        Vvelarde
        Community Champion

        Cramos

         

        Try using this Dax:

         

        NewDate =
        IF (
            Table1[Date1] = BLANK (),
            IF ( Table1[Date2] = BLANK (), Table1[Date3], Table1[Date2] );
            Table1[Date1]
        )

         

         

         

         

  •  I am facing a problem in the similar lines.

     

    I am trying to evaluate if the date is bank but if function in DAX is not evaluating the date column (that is- the date column is greyed out) is it because I am using DirectQuery???

     

    Is there any work around for this.?

    Thanks

     

    Harshad

    • MAkiva1's avatar
      MAkiva1
      Helper I

      Try creating a new custom column instead of a new measure.  You may need to switch from DirectQuery to do this however.