Saturday, January 28, 2017

How to use SUMMARIZECOLUMNS Function (DAX) in Power BI and SSAS Tabular

SUMMARIZECOLUMNS function returns a summary table over a set of groups. This new function is included in SQL Server 2016 Analysis Services (SSAS), Power Pivot in Excel 2016, and Power BI Desktop. SUMMARIZECOLUMNS, which is a replacement of SUMMARIZE and does not require the use of ADDCOLUMNS to obtain good performance
Power BI
SUMMARIZECOLUMNS function is very useful in Power BI report, especially to produce summarize/group/aggregate tables.
For example, if you need to create a summary table for sales value by subcategory, a year with some filters.
Summary Product Subcategory = SUMMARIZECOLUMNS
(
'Product Category'[Category],
'Product Subcategory'[Subcategory],
'Date'[Calendar Year],
FILTER('Product Category','Product Category'[Category]="Audio"),
"Total Sales",'Sales'[Sales Amount]
)
SSAS Tabular
You can use the function in SSAS cubes in similar ways, but you need to be aware how to use the syntaxes.
The following examples will give a clear idea about how to use SUMMARIZECOLUMNS function.


EVALUATE
SUMMARIZECOLUMNS
(
'Date'[Calendar Year],
"Total Sales",'Internet Sales'[Internet Total Sales]
)
EVALUATE
SUMMARIZECOLUMNS
(
'Product Category'[Product Category Name],
'Date'[Calendar Year],
"Total Sales",'Internet Sales'[Internet Total Sales]
)
EVALUATE
SUMMARIZECOLUMNS
(
'Product Category'[Product Category Name],
'Date'[Calendar Year],
FILTER('Date','Date'[Calendar Year]=2014),
"Total Sales",'Internet Sales'[Internet Total Sales],
"Total Units",'Internet Sales'[Internet Total Units]
)
EVALUATE
SUMMARIZECOLUMNS
(
'Product Category'[Product Category Name],
'Date'[Calendar Year],
FILTER('Date','Date'[Calendar Year]=2014),
"Total Sales",'Internet Sales'[Internet Total Sales],
"Total Sales with Correction",'Internet Sales'[Internet Total Sales]*0.99,
"Total Units",'Internet Sales'[Internet Total Units]
)


EVALUATE
SUMMARIZECOLUMNS
(
'Product Subcategory'[Product Subcategory Name],
'Date'[Calendar Year],
FILTER('Product Category','Product Category'[Product Category Name]="Bikes"),
"Total Sales",'Internet Sales'[Internet Total Sales],
"Total Units",'Internet Sales'[Internet Total Units]
)
Cheers! Uma

8 comments:

  1. Wonderful blog,Thanks for all the information you have provided. Business Analyst Online Training

    ReplyDelete
  2. Hi,
    You can have such summarizations by simply putting the necessary fields in Power BI visual if you have proper relationships defined, can't you? What is then practical use of SUMMARIZECOLUMNS?

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. It's so nice article thank you for sharing a valuable content. Power BI Online Training Bangalore

    ReplyDelete
  5. I feel Power BI is the most useful and resource full tool that can easily take up more and more complex database operations and solutions and possibly recommend a simpler version of this.

    Powerbi Read Rest

    ReplyDelete