• Skip to main content
  • Skip to footer

Curbal

Learn how to grow your business with your data and Power BI

  • Data Stories
    • Power BI Stories
    • 1 dataset, 100 matplotlib visualizations
  • Learning Portal
    • Download Center
    • 25 Days Challenge
    • DAX Glossary
    • Power BI
    • Power BI by Topic
    • Python
    • 1 dataset, 100 matplotlib visualizations
  • Courses
    • Power BI Mini Master Class 1: Using a REST API as a data source
    • Power BI Master Class 1: COVID Tracker
    • Introduction to Power BI – FREE Online course
    • M Language + Power Query Course Bundle
    • Power Query Online Training [updated 2022]
    • M Language Online Course: The unofficial and Practical Reference Guide [updated 2025]
    • My Courses
  • Shop
    • Courses
    • Master Classes
    • Template Apps
    • JSON Themes
  • Cart
  • Register/ Log In
    • Become a Member
    • Log In
    • My account
    • My Courses
  • Search
  • Contact
You are here: Home / CM Tooltip Glossary Pro+ / GROUPBY

GROUPBY

posted on April 13, 2018

« Back to Glossary Index

Syntax

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

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.

DAX Fridays! #77: GROUPBY, CURRENTGROUP

Links to the mentioned resources

To get the files:
1. Go to Curbal Download Center > Dax Fridays
2. Get File #77

Remarks

  • 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.

    Notes:

    • 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.
Was this helpful?
See Also:
  • CURRENTGROUP
  • ISSUBTOTAL
  • ROLLUP
  • ROLLUPADDISSUBTOTAL
  • ROLLUPGROUP
« Back to Index

Reader Interactions

Comments

  1. Patrick Tsang

    August 14, 2018 at 8:57 am

    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!

    Reply
    • Ruth Pozuelo Martinez

      August 14, 2018 at 9:21 am

      Hi Patrick,

      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:
      https://curbal.com/blog/joining-table-in-power-bi-with-power-query-and-dax

      /Ruth

      Reply
  2. Kamal Mukhi

    May 19, 2018 at 9:36 pm

    Hi Ruth,

    The link opens for the pbix file of the function REPT().

    Could you please check?

    Thanks & Regards,
    Kamal Mukhi

    Reply
    • Ruth Pozuelo Martinez

      May 21, 2018 at 4:21 pm

      Hi Kamal!
      Fixed!
      https://gofile.me/2kEOD/3r9RVsAY6
      /Ruth

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Footer CTA

Join our community of +50,000 professionals

Become a Member

Subscribe to YouTube

About me:

Curbal AB
Badhusgatan 7B
722 15 – Västerås
Sweden

OrgNo: 5569680852 | VAT: SE556968085201

 

Location:

© Copyright 2014-2025 · Curbal AB · All Rights Reserved · Privacy Policy · Terms of Service · Refund Policy · Log In