0
0
Power-biHow-ToBeginner ยท 3 min read

How to Use SUM in DAX in Power BI: Simple Guide

In Power BI, use the SUM function in DAX to add all numbers in a single column. The syntax is SUM(ColumnName), where ColumnName is the column you want to total. This function returns the sum of all values in that column for the current filter context.
๐Ÿ“

Syntax

The SUM function adds all numeric values in a specified column.

  • SUM(ColumnName): Adds all numbers in ColumnName.
  • ColumnName must be a column with numeric data.
  • Returns a single number representing the total.
DAX
SUM(TableName[ColumnName])
๐Ÿ’ป

Example

This example shows how to create a measure that sums the SalesAmount column in the Sales table.

DAX
Total Sales = SUM(Sales[SalesAmount])
Output
If Sales[SalesAmount] contains values: 100, 200, 300, the measure returns 600
โš ๏ธ

Common Pitfalls

Common mistakes when using SUM include:

  • Trying to sum a column with non-numeric data causes errors.
  • Using SUM on a calculated column that returns text will fail.
  • For multiple columns, SUM works only on one column at a time.
  • Confusing SUM with SUMX, which iterates over a table.
DAX
/* Wrong: summing text column */
Total Names = SUM(Customers[Name])

/* Right: sum numeric column */
Total Age = SUM(Customers[Age])
๐Ÿ“Š

Quick Reference

FunctionDescriptionExample
SUMAdds all numbers in a columnSUM(Sales[Amount])
SUMXSums an expression over a tableSUMX(Sales, Sales[Quantity] * Sales[Price])
AVERAGECalculates average of a columnAVERAGE(Sales[Amount])
COUNTCounts non-blank valuesCOUNT(Sales[OrderID])
โœ…

Key Takeaways

Use SUM(ColumnName) to add all numeric values in a single column.
SUM works only on numeric columns, not text or mixed data.
SUM returns a single total number based on current filters.
For row-by-row calculations, consider SUMX instead of SUM.
Check data types to avoid errors when using SUM.