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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

ADDCOLUMS in front of SUMMARIZE

Good Afternoon everyone

I have a case. I want to calculate the count of the salesperson that has sales performance beyond the budget/estimation. 

This is my initial DAX Code:

Count of Overbudget Salesperson =
var temp =
SUMMARIZE(Actual Sales table, SalespersonName,DimYearMonth[YearMonth],"tmp Actual Sales",[Actual Data],"tmp Budget Sales",[Budget Sales])
var result = CALCULATE(COUNTROWS(FILTER(tmp,[tmp Actual Sales]>[tmp Budget Sales])))
RETURN result

It doesn't give the intended result

But if I add ADD COLUMNS DAX in front of SUMMARIZE, the result will be correct. Like this:
var temp =
ADDCOLUMNS(SUMMARIZE(Actual Sales table, SalespersonName,DimYearMonth[YearMonth]),"tmp Actual Sales",[Actual Data],"tmp Budget Sales",[Budget Sales])

Why is this happening? What is the difference?

Thank you
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , do your actual data or budget data use some row context or across period values. In this case, summarize does work well, we have use addcolumns

 

refer this article if needed

https://www.sqlbi.com/blog/marco/2012/09/04/optimize-summarize-with-addcolumns-in-dax-ssas-tabular-dax-powerpivot/

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , do your actual data or budget data use some row context or across period values. In this case, summarize does work well, we have use addcolumns

 

refer this article if needed

https://www.sqlbi.com/blog/marco/2012/09/04/optimize-summarize-with-addcolumns-in-dax-ssas-tabular-dax-powerpivot/

Anonymous
Not applicable

But why does the difference of result happen whether you use ADDCOLUMNS or not?

 

Thank you

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.