Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

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

6 Replies

  • Anonymous , 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"
    )

  • Anonymous's avatar
    Anonymous
    Not applicable

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

  • 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.

  • FaiyazN's avatar
    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.