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
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Users Online
Currently online: 521 members 4,377 guests
Please welcome our newest community members: