'Time Conversion of seconds to HH:mm:SS
I need help with understanding how to convert seconds in integers to a HH:mm:ss format to be displayed in Quicksight Analysis.
My org is pulling its own data from REST APIs of tools being provided to us as a service from various vendors. Some of this data has time spent data measured in seconds. I know this is an easy fix in Power BI, however, i am still new to Quicksight and trying to understand how this can be achieved here. I need to be able to do aggregations on the time in seconds and then display the result in the HH:mm:ss format. For e.g. Handle time of 184, 436, 346 seconds respectively should give an Average Handle time of 00:05:22 and total handle time of 00:16:06. I cannot make changes to the tables in Athena using SQL and need to be able to do this at the dataset level or Analysis level in Quicksight. Please help me understand how this can be achieved.
Thanks in advance!!
Solution 1:[1]
Currently conversion of seconds to hh:mm:ss
in AWS QuickSight is only available by creating a calculated field with the following function:
concat(toString(floor({field_with_seconds}/3600)),':',toString(floor(({field_with_seconds}%3600)/60)),':',toString({field_with_seconds}%60))
Solution 2:[2]
I found issues with the above and rolled my own.
concat(toString(floor(sum(durationSeconds) / 86400)), "D:", substring(formatDate(addDateTime(sum(durationSeconds), "SS", parseDate("2000-01-01 00:00:00", "yyyy-MM-dd HH:mm:ss")), "dd-MM-yyyy HH:mm:ss"), 12, 10))
This method allows you to use this in aggregates and uses the date field to auto-convert seconds into hours minutes seconds without having to do date math. The other added feature is the first part that gives you # of Days.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | denis colomiet |
Solution 2 |