Group By


    Let's start aggregating and computing values for groups of data in our report model.

    This an example of "Total Sales Of Each Product"
    
class GroupByIntro(SlickReportView):
    
    report_model = SalesLineTransaction
    date_field = 'transaction_date'

    group_by = 'product'
    # We can group_by a foreign key or date field

    columns = ['name',
               SlickReportField.create(method=Sum, field='value', name='value__sum', verbose_name=_('Total sold $'))
               # a Slick Report Field is responsible for carrying on the needed calculation(s).
               ]

                

Live Example

Filters

Results

Name Total sold $
Product 0 8204
Product 1 8946
Product 2 8546
Product 3 8888
Product 4 8495
Product 5 8493
Product 6 8065
Product 7 8711
Product 8 7575
Product 9 8339