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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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"
)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.