SUMMARIZE – groupping in data models (DAX – Power Pivot, Power BI)
This article is about SUMMARIZE function, which groups rows in data models. It¨s little similar to Pivot Tables in common Excel or to groupping in Power Query (Get and Transform). The result of SUMMARIZE is always a table. Which means it can be used in new table in data models, or, in combination with other function, for new measure or new column creation - so as it results in one number.
We will use this table with animals:
If you want to see, for example, average ages and total counts by animal kinds, write this:
- Totals = SUMMARIZE('Table',
"Average age per kind",
"Number of them",
- Totals = SUMMARIZE('Table', - name of result table, function and name of source table
'Table'[Animal], - column used for grouping (you can have more of them)
"Average age per kind", - name of new column with calculation (header)
AVERAGE('Table'[Age (years)]), - calculation of new column
"Number of them", - name of another column with calculation
COUNT('Table'[Age (years)])) - calculation of another column
The result will be like this:
You can simply use SUMMARIZE or GROUPBY to get the number of unique rows, based on more columns than 1.