Modulo: Converting Seconds into Hours, Minutes, and Seconds (Tableau & Alteryx)

As described in my previous blog post, the method used is an application of the modulo operator.

In some cases, you may need to convert an elapsed time into hours, minutes and seconds. This might be the case if the elapsed time is in standard units i.e. seconds.

The Logic

In order to convert the Elapsed Time we have to use the modulo operation. To get the Hours we have to divide the number of seconds by 3600 (because there are 3600 seconds in an hour) and also use the FLOOR function. To get the Minutes we have to divide the Elapsed Time by 60 first and then use the modulo operation with 60 as the divisor. Lastly, to get the seconds we only have to use the modulo operation with 60 as the divisor.

Tableau

In Tableau we have to create three separate calculated fields based off of the Elapsed Time (Seconds):

This is the resulting data for a given set of Elapsed Times:

Alteryx:

In Alteryx we use the Formula tool. We can either use three separate Formula tools or we can create the fields inside a single Formula tool:

For the same set of Elapsed Times as in the Tableau example, this is our result:

Nice and easy (hopefully).


Link to all of my other blog posts on the Modulo operation

Tableau Public

Twitter

LinkedIn

Author:
Henry Mak
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2024 The Information Lab