Skip to main content
Back to Blog

Power BI GROUPBY Function Guide

Errin O'Connor
8 min read

The Power BI GROUPBY DAX function groups a table by one or more columns and applies aggregation functions. This reference covers syntax, enterprise use cases, performance tradeoffs, and comparison with SUMMARIZE.

Key Facts

  • GROUPBY is a DAX table function that groups rows by specified columns.
  • Use iterator functions (SUMX, COUNTX) inside GROUPBY — standard aggregates (SUM, COUNT) do not work.
  • GROUPBY must reference CURRENTGROUP() for aggregation — this is its key difference from SUMMARIZE.
  • GROUPBY is used inside ADDCOLUMNS expressions, not standalone.
  • SUMMARIZE is preferred for most grouping scenarios — GROUPBY is for specific intermediate aggregation cases.

Power BI GROUPBY Function: Enterprise Reference

GROUPBY Syntax

GROUPBY takes a table as its first argument, followed by grouping columns, then ADDCOLUMNS-style column definitions using CURRENTGROUP() for aggregation.

GROUPBY vs SUMMARIZE

SUMMARIZE is the standard DAX function for grouping a table by columns and adding aggregated measures. Use it for most grouping scenarios.

GROUPBY is designed for use inside ADDCOLUMNS when you need to aggregate over intermediate table results. It is less common and more specialized than SUMMARIZE.

  • Use SUMMARIZE when adding measures from the data model.
  • Use GROUPBY when aggregating a result table generated by ADDCOLUMNS or another table function.
  • Never use standard aggregates (SUM, COUNT) inside GROUPBY — use SUMX, COUNTX, AVERAGEX instead.
  • Always reference CURRENTGROUP() as the table argument for iterators inside GROUPBY.

Common GROUPBY Patterns

A common GROUPBY pattern groups an intermediate ADDCOLUMNS result and applies a second-level aggregation. This is useful for ranked or percentile calculations.

Performance Considerations

GROUPBY iterates over the result table row-by-row. For large tables, this can be slower than SUMMARIZE. Profile with DAX Studio before using GROUPBY in production models.

  • Prefer SUMMARIZE + CALCULATE for most enterprise grouping scenarios.
  • Use VertiPaq Analyzer to check model size after adding GROUPBY calculations.
  • Test GROUPBY measures in DAX Studio to measure query time before publishing.

Frequently Asked Questions

What does the GROUPBY function do in DAX?

GROUPBY groups a table by one or more columns and applies aggregation functions using CURRENTGROUP(). It works similarly to SUMMARIZE but is designed for use inside ADDCOLUMNS expressions.

When should I use GROUPBY vs SUMMARIZE?

Use SUMMARIZE for most grouping scenarios — it is more flexible and supports external measures. Use GROUPBY only when you need to aggregate over intermediate results inside ADDCOLUMNS.

What aggregations work with GROUPBY?

GROUPBY supports SUMX, AVERAGEX, MINX, MAXX, COUNTX, and other X-suffix iterators applied to CURRENTGROUP(). Standard aggregation functions like SUM and COUNT do not work directly inside GROUPBY.

Does GROUPBY work in calculated columns?

No. GROUPBY returns a table and must be used in a table expression context — typically inside ADDCOLUMNS or as a source for CALCULATE. It is not valid in a calculated column expression.

What are common errors with GROUPBY?

The most common error is using standard aggregation functions (SUM, COUNT) instead of iterator functions (SUMX, COUNTX) inside GROUPBY. Always wrap aggregations in an iterator with CURRENTGROUP() as the table argument.

Get Expert Help

EPC Group architects have completed 1,500+ Power BI deployments. Call (888) 381-9725 or send an inquiry and EPC Group replies to arrange a call.

DAX
-- GROUPBY with CURRENTGROUP() and an iterator (SUMX):
Sales by Category =
GROUPBY(
    Sales,
    Sales[Category],
    "Total", SUMX(CURRENTGROUP(), Sales[Amount])
)

Worked examples: grouping in Power Query, in DAX and on the report canvas

“Group by” means three different things in Power BI, and each runs at a different moment. Power Query groups rows once, when the data refreshes. The DAX GROUPBY function groups rows at query time, inside a calculation. Visual groups and bins regroup values only for display. The examples below come from the 2024 version of this guide, rewritten against current Microsoft Learn documentation (sources at the end of this section).

1. Power Query: summarize a table at refresh

Use this when the report never needs the detail rows, for example a sales table that is only ever reported by country and sales channel.

  1. In Power BI Desktop, select Home > Transform data to open Power Query Editor, then select the query that holds the rows.
  2. Select Group by. Microsoft lists three places for it: the Home tab (Transform group), the Transform tab (Table group) and the right-click menu on selected columns.
  3. Choose Advanced to group by more than one column, pick Country, select Add grouping and pick Sales Channel.
  4. Under New column name enter Total units, set Operation to Sum and Column to Units, then select OK.

Power Query records the step in M. The type annotation it adds depends on the column's data type:

Power Query M
= Table.Group(
    Source,
    {"Country", "Sales Channel"},
    {{"Total units", each List.Sum([Units]), type number}}
)

The dialog offers Sum, Average, Median, Min, Max, Count rows, Count distinct rows and All rows. Percentile and Count distinct values are available only in Power Query Online.

2. Power Query: keep the best row of each group

Group by Country and Sales Channel again, add Total units (Sum of Units) and a second column, Products, with the All rows operation. Each Products cell now holds a [Table] with that group's rows. Add a custom column named Top performer product with the formula Table.Max([Products], "Units"), expand its Product and Units fields, then remove the Products column. The result is one row per country and channel with its total and its best-selling product.

3. DAX: GROUPBY over an intermediate result

Microsoft documents GROUPBY for aggregating the output of another table expression; for aggregations over the physical tables in the model it points to SUMMARIZECOLUMNS or SUMMARIZE. This query, Microsoft's own example, totals sales by country and product category, then returns the largest category total in each country:

DAX query
DEFINE
    VAR SalesByCountryAndCategory =
        SUMMARIZECOLUMNS (
            Geography[Country],
            Product[Category],
            "Total Sales", SUMX ( Sales, Sales[Price] * Sales[Qty] )
        )
EVALUATE
GROUPBY (
    SalesByCountryAndCategory,
    Geography[Country],
    "Max Sales", MAXX ( CURRENTGROUP (), [Total Sales] )
)

Two rules decide whether a GROUPBY expression is valid. Every column it adds must aggregate CURRENTGROUP() with one of the X functions Microsoft lists: AVERAGEX, COUNTAX, COUNTX, GEOMEANX, MAXX, MINX, PRODUCTX, STDEVX.S, STDEVX.P, SUMX, VARX.S or VARX.P. And unlike SUMMARIZE, GROUPBY performs no implicit CALCULATE for those columns, so the group is not placed into the filter context.

4. DAX: the average of monthly totals, as a calculated table

The same pattern answers questions that need two levels of aggregation, such as each category's average monthly sales. The inner SUMMARIZECOLUMNS totals each month; GROUPBY averages those totals per category:

DAX calculated table
Category Monthly Average =
VAR MonthlySales =
    SUMMARIZECOLUMNS (
        'Date'[Year],
        'Date'[Month],
        Product[Category],
        "Monthly Sales", SUMX ( Sales, Sales[Price] * Sales[Qty] )
    )
RETURN
    GROUPBY (
        MonthlySales,
        Product[Category],
        "Average Monthly Sales", AVERAGEX ( CURRENTGROUP (), [Monthly Sales] )
    )

5. On the report canvas: groups and bins

A table visual has no Group By button. To combine values for display, select two or more data points in a visual with Ctrl, right-click one of them and choose Group, or right-click a field in the Fields pane and choose New group. For numeric and date fields, New group also sets a bin size, and Power BI adds a field whose name ends in (bins). Bins work on columns, including calculated columns, but not on measures.

Which one to use

  • The report never needs the detail rows: Power Query Group by, so the model stores only the summary.
  • A second-level aggregation over a table computed in DAX, such as the best category or the average of monthly totals: GROUPBY with CURRENTGROUP().
  • Ordinary grouped totals over model tables in a query or a calculated table: SUMMARIZECOLUMNS.
  • Regrouping categories or value ranges for one visual: a visual group or bin.

Corrections to earlier answers on this page

  • GROUPBY is not limited to use inside ADDCOLUMNS. Microsoft's own example, above, uses it directly in an EVALUATE query over a variable table.
  • Microsoft lists GROUPBY as applying to measures, calculated columns and calculated tables. It is not supported in DirectQuery mode when used in calculated columns or row-level security rules, and it is discouraged in visual calculations.

Sources: Microsoft Learn, “GROUPBY” (DAX function reference, ms.date 2023-10-20); “Grouping or summarizing rows” (Power Query, ms.date 2026-04-08); “Use grouping and binning in Power BI Desktop” (ms.date 2026-08-24). All read 2026-11-19.

Related Power BI & Microsoft guides

Last updated by Errin O'Connor, Founder & Chief AI Architect, EPC Group

Why Organizations Choose EPC Group

EPC Group is a Houston-based Microsoft consulting firm with enterprise implementation since 1997 experience and over 10,000 successful deployments across Power BI, Microsoft Fabric, SharePoint, Azure, Microsoft 365, and Copilot. We serve organizations across all industries including Fortune 500, federal agencies, healthcare, financial services, government, manufacturing, energy, education, retail, technology, and global enterprises.

What sets EPC Group apart is our governance-first approach. Every engagement begins with a security and compliance assessment. Our team of senior architects brings hands-on delivery experience across HIPAA, SOC 2, FedRAMP, and CMMC environments. We own outcomes, not hours.

  • Fixed-fee accelerators with predictable pricing and defined deliverables
  • Senior architect engagement on every project, not rotating juniors
  • Compliance-native delivery for regulated industries
  • End-to-end coverage from strategy through managed services
  • 11,000+ enterprise engagements refined into repeatable, risk-controlled patterns

Call (888) 381-9725 or email contact@epcgroup.net for a free assessment.

Power BI Strategy: 2026 Considerations for Power BI Groupby

Row-level security (RLS) and object-level security (OLS) in Power BI Premium and Fabric F-SKU capacities are the single most-overlooked compliance control in HIPAA, SOC 2, and FINRA-regulated environments. Microsoft documents RLS as roles with DAX filter expressions defined in Power BI Desktop, members assigned in the Power BI service and each role checked with Test as role; RLS applies to workspace Viewers only, service principals cannot be added to an RLS role, and an embedding app that signs in with a service principal applies per-user RLS by passing an effective identity in the embed token (Microsoft Learn, accessed 2026-10-28). EPC Group tests RLS with the real effective identity of each deployment scenario, because Test as role cannot simulate embedded or B2B guest identities.

Power BI Copilot grounds itself on the semantic model, NOT the underlying source data. That means Copilot answers are only as accurate as the DAX measure definitions, the field metadata (display folders, descriptions, hierarchies), and the synonyms taxonomy. In practice, the difference between a Copilot deployment that analysts keep using and one they abandon is whether the semantic model was Copilot-prepared: measure descriptions written, synonyms defined, and hierarchies and display folders curated before the first prompt is typed.

Decision factors EPC Group evaluates

  • Direct Lake mode adoption for Fabric-resident semantic models
  • License optimization audit (Pro vs Premium Per User vs F-SKU)
  • Row-level security via service principal authentication
  • Capacity sizing decision (F2/F4/F64+) tied to peak concurrent users and refresh window
  • Copilot grounding quality assessment of semantic-model metadata

For a tailored read on this topic in your specific tenant, contact EPC Group at contact@epcgroup.net or +1 (888) 381-9725. See pricing and engagement models.

AI assistant — not a human