Knowledge Base
Open App
KB 100600

Summarize extended columns


Extended columns have been added within SUMMARIZE instead of using ADDCOLUMNS for the aggregations and SUMMARIZE only for the grouping columns.

Remarks

The SUMMARIZE behavior for aggregations may produce slower performances compared to an equivalent construct where ADDCOLUMNS extends the result of SUMMARIZE by adding the columns with the calculations.

Recommended articles:

Example

Embed SUMMARIZE in an ADDCOLUMNS function moving there the aggregation expressions and the corresponding columns. Add CALCULATE for aggregations to get the equivalent filter context for the argument.

Original code

SUMMARIZE (
    Sales,
    Customer[Country], 
    'Product'[Brand], 
    "Revenues", [Sales Amount],
    "Transactions", COUNTROWS ( Sales ),
    "Short Country", LEFT ( Customer[Country], 3 )
)

Possible optimization

ADDCOLUMNS (
    SUMMARIZE (
        Sales,
        Customer[Country], 
        'Product'[Brand]
    ), 
    "Revenues", [Sales Amount],
    "Transactions", CALCULATE ( COUNTROWS ( Sales ) ),
    "Short Country", LEFT ( Customer[Country], 3 )
)