Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

How to SUMX a column created with SUMMARIZECOLUMNS

I have the following DAX statement

 

SUMMARIZECOLUMNS(
'Customer'[CustomerID]
,'Reporting Date'[YYYYMM]
,"New Column", <some logic>
)

and when I run this in an SSMS query, column [New Column] is returning the values I want. Now, in Power BI I have created this measure to return the sum of this new column:

Measure for New Column =
    SUMX(
        SUMMARIZECOLUMNS(
            'Customer'[CustomerNumber]
            ,'Reporting Date'[YYYYMM]
            ,"New Column", <some logic>
        )
        ,[New Column]
    )

But I receive this error:

Calculation error in measure: 'Measure for New Column': SummarizeColumns() and AddMissingItemsd() may not be used in this context.

 

Any ideas how I can, within a measure,  sum the columns created in a SUMMARIZECOLUMNS statement?

2 REPLIES 2
daxer-almighty
Solution Sage
Solution Sage

SUMMARIZECOLUMNS is only for queries, not for measures, since this function can't be used in context transition. Secondly, SUMMARIZE is for grouping only, not for any calculations (despite the documentation saying to the contrary). To simulate SUMMARIZE with calculations, you should use the hybrid: ADDCOLUMNS/SUMMARIZE. It's the only reliable way to do what you want. If you want to know why, you can read this: https://www.sqlbi.com/articles/all-the-secrets-of-summarize/

 

MattAllington
Community Champion
Community Champion

You cannot use SUMMARIZECOLUMNS as the first parameter of a SUMX.  You should use SUMMARIZE instead.  Make sure the first parameter of SUMMARIZE is the fact table connected to your dimension tables.



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.