This week, a customer asked for advice on how to convert seconds into HH:MM:SS in Tableau. They had created their seconds field by using a datediff calculation (that is, a calculation between a start and an end datetime field), but they weren’t happy with displaying thousands of seconds as the result.

So, they asked, is there a way to display a bunch of seconds into a format we are more used to, such as hour-minutes-seconds or hh:mm:ss?

Indeed, there’s a more than one way to do that, and in this post I am going to show you my favorite. All the credits for this solution goes to Rajeev Pandey on the Tableau Community website.

However, since there is one key step missing in Rajeev’s explanation, I have summarised the steps for you below:


1. Duplicate your seconds field, let’s call the copy: Seconds (copy)

2. Change the default properties of Seconds (copy) by setting them to custom and typing hh:mm:ss

3. Create a calculated field called with the formula:  [Seconds (copy)]/86400. I call the new field GOAL 

4. Once again, change the default properties of the calculated field GOAL by setting them to custom and typing hh:mm:ss

5. Make sure that the calculated field GOAL is a measure.

6. Drag the field to the view

Here you have it! We managed to convert a seconds field into a more easily understandable hh:mm:ss format in few steps. As you can see in the video above, the field is flexible and re-calculates the total time per id or per second according to what you choose to drag in the view.

Thank you for reading!


Do you want to learn more about Tableau, Alteryx or Snowflake? Do you want to use these tools to their full potential? Check out our trainings and consultancy services!

Bel ons

Afspraak

Mail ons