A
C
- CALCULATE
- CALCULATETABLE
- CALENDAR
- CALENDARAUTO
- CEILING
- CHISQ.DIST
- CHISQ.DIST.RT
- CHISQ.INV
- CHISQ.INV.RT
- CLOSINGBALANCEMONTH
- CLOSINGBALANCEQUARTER
- CLOSINGBALANCEYEAR
- COALESCE
- COLUMNSTATISTICS
- COMBIN
- COMBINA
- COMBINEVALUES
- CONCATENATE
- CONCATENATEX
- CONFIDENCE.NORM
- CONFIDENCE.T
- CONTAINS
- CONTAINSROW
- CONTAINSSTRING
- CONTAINSSTRINGEXACT
- CONVERT
- COS
- COSH
- COT
- COTH
- COUNT
- COUNTA
- COUNTAX
- COUNTBLANK
- COUNTROWS
- COUNTX
- COUPDAYBS
- COUPDAYS
- COUPDAYSNC
- COUPNCD
- COUPNUM
- COUPPCD
- CROSSFILTER
- CROSSJOIN
- CUMIPMT
- CUMPRINC
- CURRENCY
- CURRENTGROUP
- CUSTOMDATA
D
E
I
N
O
P
R
S
- SAMEPERIODLASTYEAR
- SAMPLE
- SEARCH
- SECOND
- SELECTCOLUMNS
- SELECTEDMEASURE
- SELECTEDMEASUREFORMATSTRING
- SELECTEDMEASURENAME
- SELECTEDVALUE
- SIGN
- SIN
- SINH
- SLN
- SQRT
- SQRTPI
- STARTOFMONTH
- STARTOFQUARTER
- STARTOFYEAR
- STDEVX.P
- STDEVX.S
- STDEV.P
- STDEV.S
- SUBSTITUTE
- SUBSTITUTEWITHINDEX
- SUM
- SUMMARIZE
- SUMMARIZECOLUMNS
- SUMX
- SWITCH
- SYD
T
U
In this article, we will explore how to use the SUM function in Power BI, including its syntax, usage, and some examples.
Syntax of the SUM Function
The syntax of the SUM function is as follows:
SUM(❰expression❱)
Here, the `❰expression❱` represents the column or the table that you want to sum up. It can be a column name, a table name, or a DAX expression that returns a table or a column.
Usage of the SUM Function
The SUM function is used to summarize data in Power BI. It is typically used in measures, which are calculations that aggregate data in a table.
Here are some common use cases of the SUM function:
Summing up a Column
To sum up a column in Power BI, you can use the SUM function in a measure. For example, if you have a Sales table with a column named Total Sales, you can create a measure to calculate the total sales as follows:
Total Sales = SUM(Sales[Total Sales])
Here, Sales[Total Sales] represents the column that you want to sum up.
Summing up Multiple Columns
You can also use the SUM function to sum up multiple columns in a table. To do this, you can add multiple columns in the expression argument of the SUM function. For example, if you have a Sales table with columns named Total Sales, Online Sales, and Offline Sales, you can create a measure to calculate the total sales as follows:
Total Sales = SUM(Sales[Total Sales], Sales[Online Sales], Sales[Offline Sales])
Here, Sales[Total Sales], Sales[Online Sales], and Sales[Offline Sales] represent the columns that you want to sum up.
Summing up Filtered Data
You can use the SUM function to sum up data that matches a certain condition. To do this, you can use the FILTER function to filter the data before using the SUM function. For example, if you have a Sales table with a column named Product Category and you want to calculate the total sales of a specific product category, you can create a measure to do this as follows:
Total Sales of Product A = SUM(FILTER(Sales, Sales[Product Category] = “Product A”), Sales[Total Sales])
Here, FILTER(Sales, Sales[Product Category] = "Product A") filters the data to include only the rows where the Product Category is "Product A". Then, SUM(..., Sales[Total Sales]) sums up the Total Sales column of the filtered data.
Examples of Using the SUM Function
Here are some examples of using the SUM function in Power BI:
Example 1: Summing up a Column
Suppose you have a Sales table with a column named Total Sales. To calculate the total sales, you can create a measure as follows:
Total Sales = SUM(Sales[Total Sales])
Example 2: Summing up Multiple Columns
Suppose you have a Sales table with columns named Total Sales, Online Sales, and Offline Sales. To calculate the total sales, you can create a measure as follows:
Total Sales = SUM(Sales[Total Sales], Sales[Online Sales], Sales[Offline Sales])
Example 3: Summing up Filtered Data
Suppose you have a Sales table with columns named Product Category and Total Sales. To calculate the total sales of a specific product category, you can create a measure as follows:
Total Sales of Product A = SUM(FILTER(Sales, Sales[Product Category] = “Product A”), Sales[Total Sales])
The SUM function is a powerful tool for summarizing data in Power BI. In this article, we have explored the syntax and usage of the SUM function, as well as some examples of how to use it. By using the SUM function, you can gain valuable insights into your data and make informed decisions based on your analysis.