OpenBI Docs Buy

SUMMARIZE

A table's groups by columns of it or of related tables, optionally with columns computed for each group.

Group: Table manipulation. Compatible with DAX.

Syntax

SUMMARIZE ( <table>, <groupBy_columnName> [, <groupBy_columnName>] … [, <name>, <expression>] … )
ParameterTypeDescription
tableTableThe table whose rows are grouped, often a fact table such as Sales.
groupBy_columnNameColumn
repeatable
A column to group by: the table's own, or a column of a table it reaches through relationships, such as Products[Category] from Sales.
nameText
optional, repeatable
The name of an added column, in quotes.
expressionExpression
optional, repeatable
Its value for each group, with the group as filter.

Returns

Table. One row for each combination of the grouping columns' values that occurs in the table's rows, with any added columns.

Remarks

  • Only combinations that occur come out: grouping Sales by category and kind of place gives no depot rows, as depots sell nothing. CROSSJOIN would list them.
  • Columns of related tables are reached along the relationships, from the many side to the one side. A column the table cannot reach is an error.
  • For added columns, prefer ADDCOLUMNS around SUMMARIZE, as in the second example: name and expression pairs inside SUMMARIZE work, but in a context that is harder to predict.
  • With ROLLUP among the grouping columns it adds subtotal rows, which ISSUBTOTAL tells apart.

Examples

The combinations that occur

EVALUATE
SUMMARIZE ( Sales, Products[Category], Places[Kind] )
ORDER BY Products[Category], Places[Kind]
Products[Category]Places[Kind]
BeerShop
CiderShop

Groups with computed columns

EVALUATE
ADDCOLUMNS (
    SUMMARIZE ( Sales, Products[Category] ),
    "Liters", [Liters sold],
    "Shops", CALCULATE ( DISTINCTCOUNT ( Sales[Shop] ) )
)
ORDER BY Products[Category]
Products[Category]LitersShops
Beer150538915
Cider30107415

A table made in the query

EVALUATE
VAR Sold =
    DATATABLE (
        "Shop", STRING, "Product", STRING, "Liters", INTEGER,
        { { "A", "Pils", 10 }, { "A", "IPA", 5 }, { "B", "Pils", 7 }, { "B", "Pils", 3 } }
    )
RETURN
    SUMMARIZE ( Sold, [Shop] )
ORDER BY [Shop]
Shop
A
B

SUMMARIZECOLUMNS, ADDCOLUMNS, GROUPBY, ROLLUP, VALUES.

Last updated · OpenBI Studio 0.3.74