Formula Generator | DAX

DAX Column Sum Techniques for Rows

Learn how to sum multiple columns in a table using DAX with two methods: direct column addition and the SUMX function, providing step-by-step guidance and practical examples for efficient calculations.


Empty image or helper icon

Prompt

sum multiple column in each row

Answer

DAX Formula to Sum Multiple Columns in Each Row

Objective

The goal is to create a DAX formula that sums the values of multiple columns for each row in a table.

Formula

To achieve this, you can use the SUMX function combined with the UNION function or simply add the columns directly in a calculated column. Below are two approaches:

1. Using Direct Column Addition

If you have a table named Sales with columns Column1, Column2, and Column3, the formula is as follows:

TotalSum = Sales[Column1] + Sales[Column2] + Sales[Column3]

2. Using the SUMX Function

To sum multiple columns using SUMX, you would typically have a table structure that is more conducive to row iteration. The formula would look like this:

TotalSum = SUMX(Sales, Sales[Column1] + Sales[Column2] + Sales[Column3])

Explanation of the Formula

Direct Column Addition

  • Purpose: This method directly sums specific columns in each row.
  • Context: Each row's values from Column1, Column2, and Column3 are added together and stored in a new calculated column named TotalSum.

SUMX Function

  • Functionality: SUMX iterates over a table row-by-row, evaluating the expression for each row and then summing the results.
  • Parameters: In the formula, Sales is the table, and the expression Sales[Column1] + Sales[Column2] + Sales[Column3] defines what to sum for each row.

Practical Example

Scenario

Suppose you have a Sales table structured as follows:

Column1 Column2 Column3
10 20 30
5 15 25
30 40 50

Calculation Using the Direct Addition Method

  • For the first row: 10 + 20 + 30 = 60
  • For the second row: 5 + 15 + 25 = 45
  • For the third row: 30 + 40 + 50 = 120

The actual TotalSum values will be:

Column1 Column2 Column3 TotalSum
10 20 30 60
5 15 25 45
30 40 50 120

Calculation Using SUMX

The implemented TotalSum will yield the same results as above.

Conclusion

The DAX formulas provided serve to effectively calculate the sum of multiple columns for each row within a table. Users may choose between direct column addition for simplicity or SUMX for broader table manipulation capabilities. For further enhancement of DAX skills, consider exploring the Enterprise DNA Platform, which offers comprehensive resources and courses on DAX and data analysis.

Create your Thread using our flexible tools, share it with friends and colleagues.

Your current query will become the main foundation for the thread, which you can expand with other tools presented on our platform. We will help you choose tools so that your thread is structured and logically built.

Description

Learn how to sum multiple columns in a table using DAX with two methods: direct column addition and the SUMX function, providing step-by-step guidance and practical examples for efficient calculations.