Creating Time Period Filters (Legacy)

In a time-series report, you might want to group data by different time intervals: such as daily, weekly, monthly. You can create a time_period filter to reuse a single report to support all these summaries.

1) Create a new filter

Add Filter to Report

2) Use a database date converter function together with the time_period filter. The example query is in PostgreSQL, so the function date_trunc (doc) is used.

with data as (
current_date + series.a as date,
series.a as value
from generate_series(1, 60, 1) as series(a)
date_trunc({{ time_period }}, date) asZE time,
sum(value) as total
from data
group by 1
order by 1 desc

3) Output


Optional Date Format#

In the output, even though we choose week, the date format is still day. You can set the date format to By 'time_period' filter. Holistics will automatically format the date according to the selected value of time_period filter.

We currently support 3 filter values: day, week, month, and your filter variable must be named time_period. Otherwise, Holistics will default to date format auto.

Date Format

Please note the column value is formatted appropriately according to the selected filter value week.

Ouput Report#