DAX Functions

GROUPBY Function

Pinterest LinkedIn Tumblr

DAX GROUPBY Function is categorized under Filter functions.

DAX-GROUPBY-Function

Purpose of DAX GROUPBY Function

This function is to get a table with the Cartesian product between each row in table1 and the table that results from evaluating table2 in the context of the current row from table1.

Return value

The  GROUPBY function returns a table with the selected columns for the groupBy_columnName arguments and the grouped by columns designated by the name arguments.

Syntax

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

Arguments

ArgumentsDescriptionRemarks
table1 Any DAX expression that returns a table. Mandatory
table2 Any DAX expression that returns a table. Mandatory
ArgumentsDescription
tableAny DAX expression that returns a table of data.
groupBy_columnNameThe name of an existing column in the table (or in a related table,) by which the data is to be grouped. This parameter cannot be an expression.
nameThe name given to a new column that is being added to the list of GroupBy columns, enclosed in double quotes.
expressionAny DAX expression that returns a single scalar value, where the expression is to be evaluated for each set of GroupBy values.

Usage notes

  • The GROUPBY function does the following:
  1. Start with the specified table (and all related tables in the “to-one” direction).
  2. Create a grouping using all of the GroupBy columns (which are required to exist in the table from step #1.).
  3. Each group is one row in the result, but represents a set of rows in the original table.
  4. For each group, evaluate the extension columns being added. Unlike the SUMMARIZE function, an implied CALCULATE is not performed, and the group isn’t placed into the filter context.
  • Each column for which you define a name must have a corresponding expression; otherwise, an error is returned. The first argument, name, defines the name of the column in the results. The second argument, expression, defines the calculation performed to obtain the value for each row in that column.
  • groupBy_columnName must be either in table or in a related table.
  • Each name must be enclosed in double quotation marks.
  • 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 Posts

Write A Comment