Forum Discussion
Summarize VS Summarizecolumn function in DAX
- 6 years ago
Hi,
Typically, it is recommended to use SummarizeColumns to add columns rather than Summarize.
Best Regards,
Giotto Zhi
Hi,
The difference is that Summarize function has several pitfalls and performance issues, and for compatibility issues it cannot be fully fixed by Microsoft.
For example, here is test table:
if you want to summarize [Product] and [Sales]*[Unit Price] as [Profit] column, maybe you will use this:
Summarize Table = SUMMARIZE('Table','Table'[Product],"Profit",SUMX('Table','Table'[Sales]*'Table'[Unit Price]))But this is not correct though it shows well.
You should use this instead of the above:
Summarize Table-2 = ADDCOLUMNS(SUMMARIZE('Table','Table'[Product]),"Profit",CALCULATE(SUMX('Table','Table'[Sales]*'Table'[Unit Price])))If you use Power BI, Analysis Services 2016, or Excel 2016(*), you can use a new DAX function called SummarizeColumns which apparently is just a replacement of Summarize:
SummarizeColumns Table = SUMMARIZECOLUMNS('Table'[Product],"Profit",SUMX('Table','Table'[Sales]*'Table'[Unit Price]))When you compare the query plans of the two versions using DAX Studio, you will notice that the SummarizeColumns is extremely efficient, requiring just one storage engine query and a smaller number of steps in the physical query plan.
Reference:
https://www.sqlbi.com/articles/introducing-summarizecolumns/
Hope this helps.
Best Regards,
Giotto Zhi
Before posting quetion here i already checked SQLBI blog.
So as i can see you got the same result with just syntax change in SUmmerizecolumn and Summerize with addcolumns.
I am still curious is there any major differance other than performance?
Thanks,
Pravin
- v-gizhi-msft6 years ago
Community Support
Hi,
Typically, it is recommended to use SummarizeColumns to add columns rather than Summarize.
Best Regards,
Giotto Zhi
- Anonymous6 years agoNot applicable
Hi v-gizhi-msft
I know it is recommended i am asking reason behind it. is it only for performance or something else?
Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar- v-gizhi-msft6 years ago
Community Support
Hi,
SummarizeColumns can use Ignore function but summarize ca not.
Reference:
Best Regards,
Giotto Zhi