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 8377
Product 1 7097
Product 2 7806
Product 3 8182
Product 4 7562
Product 5 8193
Product 6 8059
Product 7 8344
Product 8 8095
Product 9 8899