Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
Natan-npc1
New Member

How to use hour as a condition with a IF in DAX

I'm creating a new column that will return something according to the time in another column. This column that will be consulted does not show the date, it only shows the time (it's like 06:30 for example).

My formula looks like this (and it doesn't work):
IF(TableName[Hour]>= 06:00 && TableName[Hour]< 12:00, "Morning") I want to do something that shows if it's morning, afternoon or night depending on the information in the [Time] column. But the above formula doesn't work... I suspect I must convert the "06:00" somehow but I still don't know how.

 

1 ACCEPTED SOLUTION
Natan-npc1
New Member

I solved the problem!
I opened my Excel and put an hour and changed its the type. Instead of hour type I chose to view the data as number.
Then, 06:00 is the same as 0.25, 14:00 is the same as 0.5833 and so on.

IF(TableName[Hour]>= 0.25 && TableName[Hour]< 0.5833, "Morning")

 

View solution in original post

1 REPLY 1
Natan-npc1
New Member

I solved the problem!
I opened my Excel and put an hour and changed its the type. Instead of hour type I chose to view the data as number.
Then, 06:00 is the same as 0.25, 14:00 is the same as 0.5833 and so on.

IF(TableName[Hour]>= 0.25 && TableName[Hour]< 0.5833, "Morning")

 

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

Check out the May 2025 Power BI update to learn about new features.

May 2025 Monthly Update

Fabric Community Update - May 2025

Find out what's new and trending in the Fabric community.