Knowledge Base
Open App
KB 100700

Function replace GROUPBY/SUMMARIZE


The GROUPBY function can be replaced by SUMMARIZE.

Remarks

The GROUPBY function should be used only when the table cannot be used in SUMMARIZE or when there are specific features of GROUPBY that are necessary for the calculation. Whenever possible, use SUMMARIZE instead of GROUPBY.

Example

Replace GROUPBY with SUMMARIZE.

Original code

SUMX (
    GROUPBY (
        'Sales',
        'Sales'[ProductKey],
        'Sales'[CustomerKey],
        'Sales'[DateKey]
    ),
    [Sales Amount]
)

Possible optimization

SUMX (
    SUMMARIZE (
        'Sales',
        'Sales'[ProductKey],
        'Sales'[CustomerKey],
        'Sales'[DateKey]
    ),
    [Sales Amount]
)