How to Calculate Total Running Hours for Complete Months in Quick Sight?

Hi Quick Sight Community,

I’m trying to calculate the total running hours for entire months based on a date range selected using two parameters: FROM and UNTIL. My goal is to include the running hours for the whole months within the selected range, regardless of which specific days are selected in the parameters.

For example:

  • If I select a date range from 10 September to 25 October, the calculation should include the running hours for 1 September to 31 October.

Hi umarabdulsattar,

Thank you for posting.

To calculate the total running hours for entire months based on a date range selected using two parameters in Amazon Quick Sight, you can follow these steps:

Create Parameters

  1. Create two date parameters: “FROM” and “UNTIL”
  2. Set appropriate default values for these parameters

Create Calculated Fields

  1. Month Start Datesql monthStart = truncDate('MM', {FROM}) ### 2. Month End Datesql monthEnd = addDateTime(1, 'MM', truncDate('MM', {UNTIL})) - 1 ### 3. Total Running Hours```sql
    totalRunningHours = dateDiff(monthStart, monthEnd, ‘HH’) + 24

1. Use the `totalRunningHours` calculated field in your visualizations
2. Add the "FROM" and "UNTIL" parameters as controls to your dashboard

This approach ensures that regardless of the specific days selected in the FROM and UNTIL parameters, the calculation will always include the entire months within the range.

Regards,
Demola
1 Like

Hi @umarabdulsattar,
It’s been awhile since we last heard from you, did you have any additional questions or comments regarding your initial post or were you able to find a work around?

If we do not hear back within the next 3 business days, I’ll close out this topic.

Thank you!

1 Like

Hi @umarabdulsattar,
Since we have not heard back, I’ll go ahead and close out this topic. However, if you have any additional questions, feel free to create a new post in the community and link this discussion for relevant information if needed.

Thank you!

1 Like