Forum Discussion
Creating conditional column based on time for another column
MAAbdullah47 wrote:
Ok I got it, but There is an error said:
"DAX comparison operations do not support comparing values of type Text with values of type Date. Consider using the VALUE or FORMAT function to convert one of the values."
What is the type of "orders.opened_at", I think it is a TEXT type, that's why you get such error.
Try to convert it to a Date/Time type and apply
Meal = IF(HOUR('order product'[orders.opened_at])<11,"Breakfast",IF(HOUR('order product'[orders.opened_at])<18,"Lunch","Dinner"))
You'll do more conversion work if "orders.opened_at" is not a valid date format text.
Please note the column contents in text all of them are correct 100% , I did this checking through R in the following command:
if( class( order_product$orders.opened_at ) == "try-error" || is.na( order_product$orders.opened_at ) ) print( "That wasn't correct!" )
It didn't give me any warning or errors.
So the assumption of text error is not possible, the problem from power bi editor.