Skip to main content

Hello Tableau Community.

 

I have a problem. I don't know how to calculate the total number of hours from a night shift (per person and then per day) when the date and time are coming from a single column. I've attached a .twbx file with some dummy data.

 

The thing is, when I tried to calculate this night shift with two columns for time (original ones, not something generated with calculations), one for start time, and one for end time, it worked perfectly. I found the hours very simple only with a DATEDIFF even if the start day differs from the end day. But it's not the case here because my real date&time are in a single column.

And I need the total number of hours to belong to the day the shift ends (eg Come 23.08.2020, 22:30 and Go 24.08.2020, 06:30) then the 8 hours belong to the 24th.

 

If anyone has a solution I would be very grateful.

Thank you!

6 answers
  1. Aug 31, 2020, 9:32 PM

    To associate the come & go pairs if there are arbitrarily many, you can use a range join or a table calculation. I am attaching one with a table calculation.

     

    Also, you have a complex calculation to generate hours:minutes:seconds format. You should just work in fractions of a day and let Tableau do the formatting for you. That's what I've done in the attached version.

0/9000