Forum Discussion
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
- Greg_DecklerCommunity Champion
Seems like you should just convert your Text string to a Date. What does your sample data look like? Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
- AnonymousNot applicable
Apologies, powerbi does not have functional buttons to insert an image. I have been having this issue all week.
- Greg_DecklerCommunity Champion
Clear your browser cache and that should fix it. Had the issue as well and that fixed the problem for me.
- v-danhe-msftMicrosoft 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