TIMESERIES
TIMESERIES splits the numbers by time and lists every period, with zeros where nothing happened. It’s the clause for trend lines.
FROM ordersSHOW totalTIMESERIES monthDURING last_12_monthsSyntax
Section titled “Syntax”TIMESERIES day | week | month | quarter | year | day_of_week | hour_of_dayDefault period
Section titled “Default period”Without SINCE or DURING, TIMESERIES picks a window for its unit:
| Unit | Window |
|---|---|
day |
The last 30 days |
week |
The last four weeks |
month |
The last three months |
quarter |
The last four quarters |
year |
The last three years |
With GROUP BY
Section titled “With GROUP BY”TIMESERIES can be combined with a grouping. Time comes first, then the field:
FROM dealsSHOW won_valueTIMESERIES monthGROUP BY ownerDURING this_yearON won_atGROUP BY month also groups by month, but lists only the months that have data. Use it for tables; use TIMESERIES for charts over time.
Running totals
Section titled “Running totals”Add WITH CUMULATIVE_VALUES to add each period to the ones before it. See WITH.