GROUPBY DAX Function in Power BI
The GROUPBY function in Power BI is a DAX function used to group rows in a table by specified columns. It allows us to aggregate data without needing to create a physical grouping in the data model, and we can create calculated tables or summarize data on the fly.
DAX Syntax GROUPBY (table [, groupBy_columnName [, groupBy_columnName [, …]]] [, name, expression [, name, expression [, …]]])
The function has the following parameters:
- table: Any DAX expression that returns a table of data.
- groupBy_columnName: The 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.
- name: The name given to a new column that is being added to the list of GroupBy columns, enclosed in double quotes.
- expression: One of the X aggregation functions with the first argument being CURRENTGROUP().
Example: Let’s create a calculated table.
DAX
Countries Average Table =
CALCULATETABLE (
GROUPBY (
Countries,
Countries[Country],
"AvgValue", AVERAGEX ( CURRENTGROUP (), Countries[Literacy Rate (%)] )
)
) The output of the above dax function is shown below:

Let’s create a calculated table, apply the filters to remove the Literacy Rate (%) have the 0 values.
DAX
Countries Average Table =
CALCULATETABLE (
GROUPBY (
Countries,
Countries[Country],
"AvgValue", AVERAGEX ( CURRENTGROUP (), Countries[Literacy Rate (%)] )
),
Countries[Literacy Rate (%)] <> 0
) The output of the above dax function is shown below:

DAX
Countries Average Measure =
AVERAGEX (
CALCULATETABLE (
GROUPBY (
Countries,
Countries[Country],
"AvgValue", AVERAGEX ( CURRENTGROUP (), Countries[Literacy Rate (%)] )
),
Countries[Literacy Rate (%)] <> 0
),
[AvgValue]
) The output of the above dax function is shown below:
