The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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?
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/
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.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
21 | |
19 | |
18 | |
16 | |
13 |
User | Count |
---|---|
38 | |
38 | |
23 | |
21 | |
17 |