cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Moderator Eric_Zhang
Moderator

Re: 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.

Capture.PNG

Re: Creating conditional column based on time for another column

Still, It said, "Cannot convert value '' of type Text to type Date."

Re: Creating conditional column based on time for another column

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.

Re: Creating conditional column based on time for another column

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. 

Re: Creating conditional column based on time for another column

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?

 

Moderator Eric_Zhang
Moderator

Re: Creating conditional column based on time for another column


@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?

Re: Creating conditional column based on time for another column

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?

 

Moderator Eric_Zhang
Moderator

Re: Creating conditional column based on time for another column


@MAAbdullah47 wrote:

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?

 


@MAAbdullah47

You can post it as plain text or upload the attachment to a network driver(Onedrive, Google Drive or any) and share the download link.

Re: Creating conditional column based on time for another column

Can You send me your email to share? 

Moderator Eric_Zhang
Moderator

Re: Creating conditional column based on time for another column


@MAAbdullah47 wrote:

Can You send me your email to share? 


zhll2046@gmail.com

Helpful resources

Announcements
New Kudos Received Badges Coming

New Kudos Received Badges Coming

Kudos to you if you earned one of these! Check your inbox for a notification.

Microsoft Implementation for Communities Wins Award

Microsoft Implementation for Communities Wins Award

Learn about the award-winning innovation that was implemented across Microsoft’s Business Applications Communities.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Kudoed Authors (Last 30 Days)
Users online (1,300)