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 January 2023
Sales February 2023
Sales March 2023
Sales April 2023
Sales May 2023
Sales June 2023
Sales July 2023
Sales August 2023
Sales September 2023
Sales October 2023
Sales November 2023
Sales December 2023
Grand Total
6952
6594
7564
6289
7360
7731
6483
6409
7286
7134
6857
7603
84262