DAX SUMMARIZECOLUMNS Function

DAX SUMMARIZECOLUMNS Function

The SUMMARIZECOLUMNS function in DAX is a powerful tool used in Power BI to group and summarize the data. It is often preferred over the older SUMMARIZE function because it’s faster, simpler to write, and works better when building reports. With SUMMARIZECOLUMNS, you can easily create summary tables, apply filters, and calculate values like total sales or quantity. In this blog, you will explore how to use the SUMMARIZECOLUMNS function in Power BI to load data, create summaries, and improve your DAX reports.

Table of Contents:

Why Use SUMMARIZECOLUMNS in Power BI?

SUMMARIZECOLUMNS is a function in DAX used in Power BI that improves query performance and code writing for you. Unlike SUMMARIZE, it identifies the correct data sources by removing unnecessary complexity. It also generates better queries, which ultimately help with large data sources. By using SUMMARIZECOLUMNS, you reduce the execution time of the query and make better reports.

Advantages of Using SUMMARIZECOLUMNS in Power BI

  • Enhanced Performance: This means better performance with less processing time and better query plans.
  • Simplified Syntax: There is better syntax since you do not need to reference the base table.
  • More Flexible Filtering: Multiple filters can be applied directly to the table.
  • Timely Reporting: Reports are cleaner and easier to combine with visuals and KPIs. 
  • Improved Context Management: Avoids unnecessary row context issues.

Sample Dataset

Tables that we use to perform calculations.

1. Sales Table

SalesIDProductColorQuantityUnit PriceYear
1LaptopSilver58002021
2LaptopBlack38502021
3PhoneSilver105002020
4TabletWhite73002021
5PhoneBlack65202022

2. Date Table

YearMonthDay
2020Jan1
2021Feb10
2022Mar15

3. Product table

ProductIDProductColor
101LaptopSilver
102LaptopBlack
103PhoneSilver
104PhoneBlack
105TabletWhite

Required Relationships:

To execute SUMMARIZECOLUMNS queries, make sure to establish the correct relationship between tables, as the wrong relationship may lead to incorrect results.

  • Date[Year] → Sales[Year](One-to-Many)
  • Sales[Product]→Product[Product](Many-to-One)

Steps to Use SUMMARIZECOLUMNS in Power BI

Let’s explore the steps to use SUMMARIZECOLUMNS in Power BI.

Step 1: Load your dataset

1. Sales Table

Sales Table

This is the Sales Table in Power BI.

2. Date Table

 Date Table

This is a Date Table in Power BI.

3. Product Table

Product Table

This is the Product Table in Power BI.

Step 2: Define your query

Create a summary of sales by year and product colour.

Go to “Model View,” click on “New Table,” and write the formula in the formula bar.

SalesSummary =

SUMMARIZECOLUMNS (

    'Date'[Year],

    'Product'[Color],

    "Total Sales", SUMX ( Sales, Sales[Quantity] * Sales[Unit Price] )

)
Define your query

Explanation:

  • SalesSummary is used to create a new table and summarize data based on the logic
  • SUMMARIZECOLUMNS() is a function used to group and summarise data by specific columns.

Step 3: Output

Output

Explanation: Here, the DAX function is used to summarize the three tables into one table.

Comparison: SUMMARIZECOLUMNS vs SUMMARIZE

FeatureSUMMARIZECOLUMNSSUMMARIZE
Syntax ComplexitySyntax is simple and easy to understand.SUMMARIZE by itself doesn’t allow expressions. To add calculations, you need to wrap them with ADDCOLUMNS
PerformancePerformance is better for large datasets.Performance is less efficient compared to SUMMARIZE.
Filtering SupportIt supports multiple filters in tables.It has limited filter options.
Ideal Use CaseThis function is used in report building and dashboards.SUMMARIZE can be used for basic grouping and is flexible, but may require additional functions for extended logic.
DebuggingHarder to debug due to filter context and reliance on engine-generated query plansEasier to debug for simple logic, but can behave unpredictably when nested or poorly scoped.

Best Practices

  • Establish Relationships: Make sure that the correct relationships are set between tables to avoid incorrect output.
  • Minimise Filters: Apply only necessary filters to avoid unnecessary data processing. Use additional filters only when needed.
  • Use Aggregation: Perform calculations using SUMX instead of using nested queries, which make queries difficult to debug.
  • Test your formula: Test your DAX formula on sample data before applying it to actual data.
  • Name Your Table: When working with multiple tables in Power BI, try to name all important tables with meaningful names to avoid any confusion.

Limitations of SUMMARIZECOLUMNS

  • No Row Context: SUMMARIZECOLUMNS operates in filter context and does not support row context by default, making row-wise operations like calculated columns behave differently.
  • Limited Debugging Support: Debugging SUMMARIZECOLUMNS is hard, as it is a complex expression.
  • Not for Complex Calculations: SUMMARIZECOLUMNS is used for aggregation but not for complex calculations.

Conclusion

SUMMARIZECOLUMNS is the best choice when you are building DAX queries, as it improves performance, is very easy to maintain, and is a powerful function that helps in aggregation tasks. Building reports in Power BI can be very efficient only if you are using SUMMARIZECOLUMNS, as it has a clear syntax and great compatibility with other DAX functions, and can be the best option in Power BI. In this blog, you have learned about SUMMARIZECOLUMNS and its usage.

To learn more about Power BI and its functions, check out this Power BI Course and also explore Power BI Interview Questions prepared by industry experts.

SUMMARIZECOLUMNS Function (DAX) – FAQs

Q1. What is SUMMARIZECOLUMNS used for?

SUMMARIZECOLUMNS is used to create a summary of a table with selected columns, which is helpful in aggregation.

Q2. How is SUMMARIZECOLUMNS different from SUMMARIZE?

SUMMARIZECOLUMNS has a simple syntax and handles filtering very well as compared to SUMMARIZE.

Q3. Can I use SUMMARIZECOLUMNS in calculated tables?

Yes, you can use SUMMARIZECOLUMNS in the calculated table, as it helps in creating a summary of the table.

Q4. Does SUMMARIZECOLUMNS support filter context?

Yes, SUMMARIZECOLUMNS supports filter context as it can apply multiple filters using filter tables.

Q5. Can I use multiple tables in SUMMARIZECOLUMNS?

Yes, you can apply SUMMARIZECOLUMNS in multiple tables, but make sure that you define the correct relationship between them.

Data Analytics for Business