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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Transform a time range into a word

Sorry, my English is bad, I use google translation.

 

Hello,

 

I work with a team in 3x8 hours, and I try to do statistics.

Here's what I've been looking for hours:

 

I have an HH:MM time column (and another hhmm),

example (FR hour Format)

05:00
05:32
13:50
19:30

 

Instead of these hours, I wish to make appear a word according to the hour:

- "Morning" between 05:00 and 13:00

- "Evening" between 13:01 and 21:00

 

I tried DAX but I can't do it (probably because I speak the international language badly :(). Also, creating a custom filter did not allow me to carry out the action.

Can you help me please ?

 

Thanks,

Bastien

1 ACCEPTED SOLUTION
harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

Create a Calculated Column

 

Column =
IF (Hour('Table'[Time]) >= HOUR(Time(5,0,0)) && HOUR('Table'[Time]) <= HOUR(Time(12,59,0)) , "Morning", "Evening")
 
1.jpg2.JPG
 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

View solution in original post

4 REPLIES 4
harshnathani
Community Champion
Community Champion

Hi @Anonymous ,

 

Create a Calculated Column

 

Column =
IF (Hour('Table'[Time]) >= HOUR(Time(5,0,0)) && HOUR('Table'[Time]) <= HOUR(Time(12,59,0)) , "Morning", "Evening")
 
1.jpg2.JPG
 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Anonymous
Not applicable

Hi @harshnathani 

 

Thank you, you put me on the right track.

It is probably related to my region but I replaced the "," by ";" for the hours "5;0;0"

 

Now I try to add a 3rd  and last condition to my column 

- "Morning" between 05:00 and 13:00

- "Evening" between 13:01 and 21:00

- "Night" between 21:01 and 04:59

 

but is impossible with the IF command (only 2 arguments).

I find a lot of information on IF ELSE.
I can't do it but I'm working on it 🙂

 

have a nice day

Hi @Anonymous 

 

Try this.

 

Column =
IF (
Table15[Time] >= TIME ( 5, 0, 0 )
&& Table15[Time] < TIME ( 12, 59, 0 ),
"Morning",
IF (
Table15[Time] >= TIME ( 13, 0, 0 )
&& Table15[Time] < TIME ( 21, 0, 0 ),
"Afternoon",
"Night"
)
)
 
 
Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)
Anonymous
Not applicable

it works very well @harshnathani 

Thank you very much for your precious help, it makes me want to go even further.

I validate the first solution because it answers the original subject.

 

regards,

Bastien

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.