Dashboard - calculations

Good morning!
I need to create a field that calculates the average payment time.
I need a syntax that returns the
how long it takes us to make payments in hours; minutes; seconds.

I’ve created this syntax but it’s not working:

AVG_hhmmss
concat(‘0’,
toString(floor({avg_seg} / 3600)), ‘:’,
ifelse(floor(({avg_seg}% 3600) / 60) < 10, concat(‘0’, toString(floor(({avg_seg}% 3600) / 60))), toString(floor(({avg_seg}% 3600) / 60))), ‘:’,
ifelse(floor({avg_seg}% 60) < 10, concat(‘0’, toString(floor({avg_seg}% 60))), toString(floor({avg_seg}% 60)))
)

Thank you and I look forward to hearing from you!

1 Like

Hello @jcolucci, welcome to the QuickSight community!

I see that you are on the right track to display this in the HH:mm:ss format, and I am assuming the issue is in the calculation you are using to return the seconds value. I think you would have to check the modulus against the hours and minutes to return only the remaining seconds rather than just checking the modulus against minutes. I believe it would look like this:
ifelse(floor(({avg_seg}% 3600) % 60) < 10, concat(‘0’, toString(floor(({avg_seg}% 3600) % 60))), toString(floor(({avg_seg}% 3600) % 60)))

That should give you the remainder of minutes from Hours, and the remaining of seconds from minutes. I’ll mark this as the solution, but let me know if you have any follow-up questions!

1 Like