Time series (without Group by)
In this example we are telling Slick Reporting to create a monthly time series for the sum of the `value` field.
However without giving a group_by, so it operate on the all the records
and gives us a one line sum of all `values` row in the report model.
class NoGroupByTimeSeries(SlickReportView):
report_model = SalesLineTransaction
date_field = 'transaction_date'
columns = ['__time_series__',
SlickReportField.create(Sum, 'value', verbose_name='Grand Total')
]
time_series_pattern = 'monthly'
time_series_columns = [
SlickReportField.create(method=Sum, field='value', name='value__sum', verbose_name=_('Sales'))
]
# A chart for our total values
chart_settings = [
{'type': 'bar',
'data_source': ['value__sum'],
'title_source': ['name'],
'title': 'Total sales per month',
'plot_total':True,
}
]
Live Example
Filters
Results
Sales 2023/01/01 - 2023/02/01
Sales 2023/02/01 - 2023/03/01
Sales 2023/03/01 - 2023/04/01
Sales 2023/04/01 - 2023/05/01
Sales 2023/05/01 - 2023/06/01
Sales 2023/06/01 - 2023/07/01
Sales 2023/07/01 - 2023/08/01
Sales 2023/08/01 - 2023/09/01
Sales 2023/09/01 - 2023/10/01
Sales 2023/10/01 - 2023/11/01
Sales 2023/11/01 - 2023/12/01
Sales 2023/12/01 - 2024/01/01
Grand Total
0
0
0
0
0
0
0
0
0
0
0
0
0