GROUPBY Function (DAX)

How does the GROUPBY function (DAX) work?

The GROUPBY function is similar to the SUMMARIZE function. However, GROUPBY does not do an implicit CALCULATE for any extension columns that it adds. GROUPBY permits a new function, CURRENTGROUP(), to be used inside aggregation functions in the extension columns that it adds. GROUPBY attempts to reuse the data that has been grouped making it highly performant.

GROUPBY Formula Syntax

GROUPBY (<table>, [<groupBy_columnName1>], [<name>, <expression>] … )

How do you use the GROUPBY function?

The function GROUPBY does the following:

− Start with the specified table (and all related tables in the direction of “to-one”).

– Creates a grouping using all the GroupBy columns. In the result, each group is one row, but represents a set of rows in the original table.

– Evaluate the columns of extensions being added for each group.

Related Blog Posts

EDNA BLOG-COMBINING-DYNAMIC-GROUPING-W-RANKING-LOGIC
EDNA Blog-Grouping and Segmenting with DAX
EDNA-BLOG-ADVANCED-CUSTOM-SEGMENTATION

Related Support Forum Posts

Groupby or Summarize
How To Use The GROUPBY Function In Power BI – DAX Function Review
Advanced Table Functions: GROUPBY

Considerations when using the GROUPBY function

  • Each column for which you define a name must have a corresponding expression. Otherwise, an error is returned.
    • The first parameter, name, defines the name of the column in the results. The second parameter, expression, defines the calculation performed to obtain the value for each row in that column.
    • Each name must be enclosed in double quotation marks.
  • groupBy_columnName must be either in a table or in a related table.
    • The function groups a selected set of rows into a set of summary rows by the values of one or more groupBy_columnName columns. One row is returned for each group.

Related Video Tutorials

Grouping & Segmenting Your Data With DAX Measure Logic - Advanced DAX
edna-tv-dynamic grouping with ranking logic

Formula examples using the GROUPBY function

GROUPBY (  
Sales,   
Geography[Country],   
Product[Category],   
“Total Sales”, SUMX( CURRENTGROUP(), Sales[Price] * Sales[Qty])  
)  

Related DAX Functions

SUMMARIZE
DAX Guide SUMMARIZECOLUMNS

Related Course Modules

Ultimate-Beginners-Guide-To-PowerBI

DOWNLOAD

To access our comprehensive DAX formula reference guide just insert your email address below. The resource will download immediately and we’ll also email it to you.