Forum Discussion

Wirestat's avatar
Wirestat
Frequent Visitor
4 years ago
Solved

Value Based on time range

Hi there, please help have trivial rutine problem need to define shift number based on time range where:

first shift duration from 7:00 to 15:30

second shift duration from 15:30 to 24:00

third shift duration from 24:00 to 07:00

and the date column in example 

Thank you in advance.

Date

09/04/2022 4:19:08 PM
09/04/2022 4:10:24 PM
09/04/2022 2:26:23 PM
09/04/2022 2:22:37 PM
09/04/2022 11:50:33 AM
09/04/2022 11:40:15 AM
09/04/2022 2:17:16 PM
09/04/2022 2:11:29 PM
09/04/2022 2:03:57 PM
09/04/2022 1:56:56 PM
09/04/2022 6:49:51 PM
09/04/2022 12:42:35 PM
09/04/2022 10:24:16 AM
09/04/2022 3:35:54 PM

 

  • Wirestat , Create a new column like

    Switch(true(),
    timevalue([Datetime]) < time(7,0,0) , "Third Shift",
    timevalue([Datetime]) < time(15,30,0) , "First Shift",
    "Second Shift"
    )

5 Replies

  • Wirestat , Create a new column like

    Switch(true(),
    timevalue([Datetime]) < time(7,0,0) , "Third Shift",
    timevalue([Datetime]) < time(15,30,0) , "First Shift",
    "Second Shift"
    )

    • Doro's avatar
      Doro
      Frequent Visitor

      Hello, and what if  some cells are empty how it will be treated?

    • Wirestat's avatar
      Wirestat
      Frequent Visitor

      Thank you, How exactly this fuction works?

      Also interested what if some cell have missing data? 

  • Hi:

    You can do this by making sure those are two separate columns. I used Power Query to do minor set up work. I'll paste below. Here is the calculated column, theTable name is Shift. If you'd like me to send file I can, just realized a lot of miscellaneous things on my pbix.. I hope this helps..

    Shift Assigned =
    Switch(true(),
    Shift[Stand Time]< TIME(7, 0 ,0) , "Third Shift",
    Shift[Stand Time] < TIME(15,30,0), "First Shift",
    "Second Shift")

     

     

    • Wirestat's avatar
      Wirestat
      Frequent Visitor

      thank you, but  amitchandak solution looks more compact