Please note javascript is required for full website functionality.

Blog

Power Pivot Principles: The A to Z of DAX Functions – CURRENTGROUP

27 December 2022

In our long-established Power Pivot Principles articles, we continue our series on the A to Z of Data Analysis eXpression (DAX) functions.  This week, we look at CURRENTGROUP.

 

The CURRENTGROUP function

The CURRENTGROUP function is one of the table manipulation functions.  It returns a set of rows from the table argument of a GROUPBY expression that belong to the current row of the GROUPBY result.  Besides that, the CURRENTGROUP function takes no arguments:

CURRENTGROUP()

It should be noted that:

  • This function can only be used in conjunction with a GROUPBY expression
  • The GROUPBY function is like the SUMMARIZE function, but the GROUPBY function will not perform an implicit CALCULATE for any extension columns it adds.  Moreover, it also permits the CURRENTGROUP function to be used inside aggregation functions in the extension columns that it adds
  • The only place the CURRENTGROUP function is supported is as the first parameter to one of the aggregation functions: AVERAGEX, COUNTAX, COUNTX, GEOMEANX, MAXX, MINXPRODUCTX, STDEVX.S, STDEVX.P, SUMX, VARX.SVARX.P.

As an example, consider the following data table:

You can use the following DAX query to return the number of customers in each country:

EVALUATE

    GROUPBY (

        Customers,

        Customer[Country],

        "# Customers",

        COUNTX ( CURRENTGROUP (), 1 )

        )

The result is as follows:

Come back next week for our next post on Power Pivot in the Blog section.  In the meantime, please remember we have training in Power Pivot which you can find out more about here.  If you wish to catch up on past articles in the meantime, you can find all of our Past Power Pivot blogs here.

Newsletter