Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Compare dates in if statement DAX

In DAX, I am comparing date columns with:

 

CurrentReportStatus = if(ReportHistory[Report Status ID 0]=ReportHistory[ReportMax],"Status 0","Status 1")

 

but am met with an error:

"DAX comparison operations do not support comparing values of type Date with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values."

 

I tried to format date columns to no avail with:

 

CurrentReportStatus = if(FORMAT(ReportHistory[Report Status ID 0],"dd/MM/YY hh:mm:ss")=FORMAT(ReportHistory[ReportMax],"dd/MM/YY hh:mm:ss"),"Status 0","Status 1")

 

the result only shows the false value, "Status 1" for the entire column:

 

 

 

4 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Apologies, powerbi does not have functional buttons to insert an image. I have been having this issue all week.

       

       

      • Greg_Deckler's avatar
        Greg_Deckler
        Community Champion

        Clear your browser cache and that should fix it. Had the issue as well and that fixed the problem for me.

  • v-danhe-msft's avatar
    v-danhe-msft
    Microsoft Employee

    Hi Anonymous,

    Could you please check if the data in [Report Status ID 0] column is the same type with the data in [ReportMax]? If so, could you please upload the sample data to have a test if possible?

     

    Regards,

    Daniel He