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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
ameerehs
Frequent Visitor

Categorize data by specific time periods

Hi there,

I was wondering how I would go about grouping data by specific time intervals during the week.

 

Priority is to calculate the data based on the following filters for the below times:
Production - Monday at 12:00 am - Friday at 11:00 pm.
Maintenance - Friday at 11:00 pm-Saturday at 4:59 pm
Non - Production - Saturday at 5:00 pm - Sunday at 3:00 pm
Maintenance - Sunday at 3:00 pm - 11:59 pm

 

Thanks

1 ACCEPTED SOLUTION

Hi @ameerehs ,

 

Try to do like this, please refer to my .pbix file.

v-lionel-msft_0-1618993819805.png

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

6 REPLIES 6
FaiyazN
Regular Visitor

Hi this was really good but when I implemented to my issue it did not work.  Can some help me with the below. I have date and time struggling to get the same out put as you got.

 

Category below

Peak - Monday to Friday between 05:00 and 16:59

Off-Peak - Monday to Friday between 17:00 and 04:59 (including Monday 00:00 to 04:59 and Friday 17:00 to Saturday 00:00)

Weekends - Saturday 00:01 until Sunday 23:59.

GuillermoSVA
New Member

Whay I'm doing wrong?....

I'm trying to use DAX formula in a new column name RealShft but I just can't.

Thanks for helping.

error shift2.PNG

ameerehs
Frequent Visitor

Thanks @amitchandak , I have tried using that but doesnt seem to recognize the Non -Production time period. 

Hi @ameerehs ,

 

Try to do like this, please refer to my .pbix file.

v-lionel-msft_0-1618993819805.png

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Thanks @v-lionel-msft After modifying it a little bit, I got it to work.

amitchandak
Super User
Super User

@ameerehs , Try like

a new column

Switch(true() ,
Weekday([Datetime],2) in {1,2,3,4} , "Production",
Weekday([Datetime],2) =5 && hour([Datetime]) <=23 , "Production",
(Weekday([Datetime],2) =5 && hour([Datetime]) <=23 ) , "Production",
(Weekday([Datetime],2) =5 && hour([Datetime]) >23) && (Weekday([Datetime],2) =6 && hour([Datetime]) <17) , "Maintenance" ,
(Weekday([Datetime],6) =6 && hour([Datetime]) > 17) && (Weekday([Datetime],2) =6 && hour([Datetime]) <= 15), "Non - Production" ,
"Maintenance"
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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