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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
mina97
Helper III
Helper III

identifying in or out work hours based on am and pm timing

i have the following input data 7 / 31/ 2023  3: 49 :51 PM 

 

and my code  is identifying this as "in work hours"

what i am looking for is from 7 am to 3 pm equal" in work "

else "out of work"

please help and thank you

 

work hours = Switch(True() ,

[Date] >=Time(7,0,0) || [Date] <time(15,0,0), "Morning",

[Date] >=Time(15,0,0) ||  [Date] <= time(7,0,0), "Evening",

"Other"

)

 

 

1 ACCEPTED SOLUTION
JoeBarry
Solution Sage
Solution Sage

Hi @mina97 

 

DAX solution

 

In the table add a Column and name it as you will.

 

Add this

 

Column = IF(TIMEVALUE(RIGHT('Table'[Column1], 11)) >= TIME(7,0,0) && TIMEVALUE(RIGHT('Table'[Column1], 11)) < TIME(15,0,0) , "Morning", "Evening")

 

JoeBarry_0-1694080611078.png

 

Thanks

Joe

 

 

If this post helps, then please Accept it as the solution

 

View solution in original post

3 REPLIES 3
JoeBarry
Solution Sage
Solution Sage

Hi @mina97 

 

DAX solution

 

In the table add a Column and name it as you will.

 

Add this

 

Column = IF(TIMEVALUE(RIGHT('Table'[Column1], 11)) >= TIME(7,0,0) && TIMEVALUE(RIGHT('Table'[Column1], 11)) < TIME(15,0,0) , "Morning", "Evening")

 

JoeBarry_0-1694080611078.png

 

Thanks

Joe

 

 

If this post helps, then please Accept it as the solution

 

 

Column = IF(TIMEVALUE(RIGHT('Table'[Column1], 11)) >= TIME(7,0,0) && TIMEVALUE(RIGHT('Table'[Column1], 11)) < TIME(3,0,0) , "Morning", "Evening")

 

Column = IF(TIMEVALUE(RIGHT('Table'[Column1], 11)) >= TIME(7,0,0) && TIMEVALUE(RIGHT('Table'[Column1], 11)) < TIME(15,0,0) , "Morning", "Evening")

i tried the code but it does not work becase i have 3 am and 3 pm and it fails to distinguesh between them 

 

please help and thank you

I'm confused

 

In the original requirement, you needed to show between 7am and 3pm  My measure works for this 

Do you have other criteria for the measure besides between 7am and 3pm? 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors