GROUPBY (<table>, , … )
Tutorial with example
In today’s DAX Fridays, we will go through the DAX function GROUPBY with an example.
GROUPBY is similar as SUMMARIZE, but the difference is that in the expression part, you use DAX iterators to get your results.
You can also nest GROUPBY functions to get for example the highest sales amount by country.
Links to the mentioned resources
To get the files:
1. Go to Curbal Download Center > Dax Fridays
2. Get File #77
- The GROUPBY function does the following:
- Start with the specified table (and all related tables in the “to-one” direction).
- Create a grouping using all of the GroupBy columns (which are required to exist in the table from step #1.).
- Each group is one row in the result, but represents a set of rows in the original table.
- 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.
« Back to Index
Was this helpful?
Hi, I am working on to put the figures of two tables into one in order to compare. One is with Item code/budget Purchases Qty./budget Purchases Amounts, the other with Item code/Actual Purchases Qty. / Actual Purchases Amounts. Can I use GROUPBY to group into one table so I can compare the Budget / Actual figures of each item? Thank you very much!
Ruth Pozuelo Martinez
You could do it better in Power Query, but if you need to do it in DAX, I think this blog post might help you:
The link opens for the pbix file of the function REPT().
Could you please check?
Thanks & Regards,
Ruth Pozuelo Martinez