Hi @jorge1. Welcome to the Community.
I entered your issue into our Community chat agent and this is what I got. I have asked @Brett to validate this when back online on Monday – but hopefully in the meantime this will help you get unblocked. Have a great weekend!
To calculate the average of a measure over a specific time period, you can use the extract function to filter data within your desired time range. You can create a calculated field that uses the extract function to check if the timestamp falls within your specified hours. 1
For example, you could use a formula like:
ifelse(extract('HH',{date_field})>=start_hour AND extract('HH',{date_field})<=end_hour, {measure}, NULL)
This calculation would only include values where the hour component of your date field falls within your specified range.
For more complex time-based calculations, you might consider using level-aware calculations (LAC) in QuickSight. These allow you to inject calculations at specific points in QuickSight’s evaluation process. 2 3
The PRE_FILTER calculation level could be particularly useful as it evaluates calculations before applying filters from the analysis. 2 3
If you need to work with specific date ranges rather than just time components, you might also find the truncDate function helpful for manipulating date values in your calculations. 4
No answer is found for a direct function with the exact syntax of avg(measure, date, start_date:end_date), but the combination of extract function with conditional logic provides a workable solution for calculating averages over specific time periods.