SUMMARIZECOLUMNS DAX Function (Table manipulation)

Create a summary table for the requested totals over set of groups.

Syntax

SUMMARIZECOLUMNS ( [<GroupBy_ColumnName> [, [<FilterTable>] [, [<Name>] [, [<Expression>] [, <GroupBy_ColumnName> [, [<FilterTable>] [, [<Name>] [, [<Expression>] [, … ] ] ] ] ] ] ] ] ] )
Parameter Attributes Description
GroupBy_ColumnName Optional
Repeatable

A column to group by or a call to ROLLUPGROUP function and ROLLUPADDISSUBTOTAL function to specify a list of columns to group by with subtotals.

FilterTable Optional
Repeatable

An expression that defines the table from which rows are to be returned.
The expression can be embedded in a NONVISUAL function, which marks a value filter in SUMMARIZECOLUMNS function as not affecting measure values, but only applying to group-by columns.

Name Optional
Repeatable

A column name to be added.

Expression Optional
Repeatable

The expression of the new column.

Return values

Table An entire table or a table with one or more columns.

A table which includes combinations of values from the supplied columns, based on the grouping specified. Only rows for which at least one of the supplied expressions return a non-blank value are included in the table returned. If all expressions evaluate to BLANK for a row, that row is not included in the table returned.

Remarks

SUMMARIZECOLUMNS does not support evaluation within a context transition. This makes it not useful in most of the measures – a measure with SUMMARIZECOLUMNS can be called also by CALCULATE but not in any case of context transition, including other SUMMARIZECOLUMNS statements. Client tools like Excel and Power BI almost always generate context transitions to evaluate measures in the reports.

SUMMARIZECOLUMNS always combines all the filters on the same table into a single filter. The combined table resulting from this filter only contains columns explicitly listed in SUMMARIZECOLUMNS as grouping columns or filter columns. This is the auto-exists behavior that has side effects on functions such as FILTERS.

Filters in SUMMARIZECOLUMNS only apply to group-by columns from the same table and to measures. They do not apply to group-by columns from other tables directly, but indirectly through the implied non-empty filter from measures. In order to apply a filter to the group-by column unconditionally, apply the filter through a CALCULATETABLE function that evaluates SUMMARIZECOLUMNS.

» 3 related articles
» 1 related function

Examples

--  SUMMARIZECOLUMNS is the primary querying function in DAX
--  It provides most querying features in a single function:
--      First set of arguments are the groupby columns
--      Second set are the filters
--      Third set are additional columns added to the resultset
EVALUATE
SUMMARIZECOLUMNS ( 
    'Product'[Brand],
    'Date'[Calendar Year],
    TREATAS ( { "CY 2008", "CY 2009" }, 'Date'[Calendar Year] ),
    TREATAS ( { "Red", "Blue" }, 'Product'[Color] ),
    "Amount", [Sales Amount],
    "Qty", SUM ( Sales[Quantity] )
)
Brand Calendar Year Amount Qty
Contoso 2008-01-01 449,704.15 1,851
Wide World Importers 2008-01-01 87,108.20 213
Northwind Traders 2008-01-01 152,389.53 263
Adventure Works 2008-01-01 74,735.98 230
Southridge Video 2008-01-01 9,902.09 688
Litware 2008-01-01 244,134.07 611
Fabrikam 2008-01-01 274,937.21 557
Proseware 2008-01-01 50,642.52 178
A. Datum 2008-01-01 27,733.20 60
Tailspin Toys 2008-01-01 22,856.00 677
Contoso 2009-01-01 298,096.75 1,703
Wide World Importers 2009-01-01 75,496.96 312
Northwind Traders 2009-01-01 73,747.19 156
Adventure Works 2009-01-01 81,845.29 216
Southridge Video 2009-01-01 10,696.16 692
Litware 2009-01-01 184,703.58 756
Fabrikam 2009-01-01 222,621.82 506
Proseware 2009-01-01 71,255.37 371
Tailspin Toys 2009-01-01 51,084.87 1,797
--  SUMMARIZECOLUMNS can compute subtotals as part of the query result
EVALUATE
SUMMARIZECOLUMNS (
    ROLLUPADDISSUBTOTAL ( 'Product'[Brand], "Brand total" ),
    ROLLUPADDISSUBTOTAL ( 'Date'[Calendar Year], "Year total" ),
    TREATAS ( { "CY 2008" }, 'Date'[Calendar Year] ),
    TREATAS ( { "Contoso", "Litware" }, 'Product'[Brand] ),
    "Amount", [Sales Amount],
    "Qty", SUM ( Sales[Quantity] )
)
ORDER BY [Year Total] ASC, [Calendar Year], [Brand Total] ASC, [Brand]
Brand Calendar Year Brand total Year total Amount Qty
Contoso 2008-01-01 false false 2,369,167.68 14,901
Litware 2008-01-01 false false 1,487,846.74 3,364
(Blank) 2008-01-01 true false 3,857,014.43 18,265
Contoso (Blank) false true 2,369,167.68 14,901
Litware (Blank) false true 1,487,846.74 3,364
(Blank) (Blank) true true 3,857,014.43 18,265
--  Blank values are automatically removed from the output, 
--  unless you use the IGNORE modifier for newly introduced
--  columns.
--  Removed rows can also be reintroduced later by using ADDMISSINGITEMS
EVALUATE
SUMMARIZECOLUMNS (
    'Date'[Calendar Year], 
    "Amount", [Sales Amount]
)

EVALUATE
ADDMISSINGITEMS ( 
    'Date'[Calendar Year], 
    SUMMARIZECOLUMNS (
        'Date'[Calendar Year], 
        "Amount", [Sales Amount]
    ),
    'Date'[Calendar Year]
)
ORDER BY 'Date'[Calendar Year]

Calendar Year Amount
2007-01-01 11,309,946.12
2008-01-01 9,927,582.99
2009-01-01 9,353,814.87
Calendar Year Amount
2005-01-01 (Blank)
2006-01-01 (Blank)
2007-01-01 11,309,946.12
2008-01-01 9,927,582.99
2009-01-01 9,353,814.87
2010-01-01 (Blank)
2011-01-01 (Blank)

SUMMARIZECOLUMNS cannot be used if the filter context contains a row context or a filter context generated by context transition or an arbitrarily shaped set. This limitation makes it unusable in any measure. It is a function intended solely for queries and calculated tables.
The following query produces an error:

EVALUATE
ADDCOLUMNS (
    VALUES ( 'Date'[Calendar Year] ),
    "Test",
        SUMX (
            SUMMARIZECOLUMNS (
                'Product'[Brand],
                "Qty", SUM ( Sales[Quantity] )
            ),
            [Qty]
        )
)

Related articles

Learn more about SUMMARIZECOLUMNS in the following articles:

Related functions

Other related functions are:

Last update: May 12, 2021   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo

Microsoft documentation: https://docs.microsoft.com/en-us/dax/summarizecolumns-function-dax

2018-2021 © SQLBI. All rights are reserved. Information coming from Microsoft documentation is property of Microsoft Corp. » Contact us   » Privacy Policy & Cookies

Context Transition

This function performs a Context Transition if called in a Row Context. Click to read more.

Row Context

This expression is executed in a Row Context. Click to read more.

Iterator

Not recommended

The use of this function is not recommended. See Remarks and Related functions for alternatives.

Not recommended

The use of this parameter is not recommended.

Deprecated

This function is deprecated. Jump to the Alternatives section to see the function to use.

Deprecated

This parameter is deprecated and its use is not recommended.

DirectQuery compatibility

Limitations are placed on DAX expressions allowed in measures and calculated columns.
The state below shows the DirectQuery compatibility of the DAX function.

Contribute

Want to improve the content of SUMMARIZECOLUMNS? Did you find any issue?
Please, report it us! All submissions will be evaluated for possible updates of the content.


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.