Forum Discussion
Creating conditional column based on time for another column
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."
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.
- MAAbdullah479 years agoHelper V
Still, It said, "Cannot convert value '' of type Text to type Date."
- MAAbdullah479 years agoHelper V
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.
- MAAbdullah479 years agoHelper V
Let me know how to convert the column into date time, I found many difficulties without clear instructions for altering the data type, I'll be appreciated if you can help me.
- MAAbdullah479 years agoHelper V
I got now how to change the text into (Date/Time) but when I try to change the type it gives the following message error:
"We can't Automatically convert the column to Date/Time Type", any advice?
- Eric_Zhang9 years agoMicrosoft Employee
MAAbdullah47 wrote:
I got now how to change the text into (Date/Time) but when I try to change the type it gives the following message error:
"We can't Automatically convert the column to Date/Time Type", any advice?
The error shows there're some text in that column not in a valid date format in your data, would you mind sharing any sample data in your case?
- MAAbdullah479 years agoHelper V
Hold On I'll try to send you the column information only, but here I cannot send it as an attachment, so what I should do?