Sumx is a function in power bi which is also an inbuilt function and it is categorized under the mathematical functions, the use of this function is to return the sum of expression from a table and the syntax used for this function is as follows SUMX(<table>,<Expression>).

## What Does SUMX Function Do in Power BI?

SUMX is an iteration function in Power BI that works on row by row calculation as per the expression or equation is given. This function takes into consideration each row at a time and applies the calculation. This will not concentrate on the entire column unlike SUM function do but it works like a cell be cell formula in excel. SUM is an aggregate function and SUMX is an expression function. Power BI data manipulation can be done by using “DAX” functions and SUMX is one such function in Power BI. In this article, we will take you through the SUMX in Power BI.

Below is the syntax of the SUMX function in Power BI.

**Table: **First thing we need to do is to supply the table name for which we are supplying SUMX function.

**Expression: **After the table, we need to provide the **Expression **or **Equation **to do row by row.

To supplying Power BI SUMX you need data to work with, so you can download the excel workbook template from the below link which is used for this example.

### Examples of SUMX Function in Power BI

Below are some examples of SUMX function in Power BI.

#### SUMX in Power BI – Example #1

For an example look at the below simple table.

- In the above table, we have units and price per unit but we don’t have Total Sale value. So by using power BI SUMX, we will find out what is the sale value.
- Upload the data table to Power BI and name the table as “Sales Table”.

- Now we need to calculate the “Total Sales” column as a new calculated column. Right-click on the table name and choose “New Column”.

- Name the new column as “Total Sales”.

- Open SUMX function now.

- First, we need to supply the table name so since our table name is “Sales Table” supply the same only.

**The expression**is nothing that is equation we need to do??- So we need to find the “Total Sales” value by multiplying Units with Price.

- Close the bracket and hit enter key to get the result in the new column.

Wow!!! It says total sales as 56658 for all the rows this is because since we have used SUMX to arrive the new column it has given us the overall total amount for all the rows. So to arrive each row calculation we need to apply the Power BI SUMX function in “New Measure” not in “New Column”.

- Right-click on the table and choose “New Measure”.

- Give measure a name as “Sale Value”.

- Now apply the SUMX function in power BI.

- Now come back to “Report Tab”.

- Insert
visual from the visualization list.*“Table”*

- Drag and drop City and “Sale Value” to get the summary table.

- This is giving us the exact result but drag and drop first calculated column i.e. “Total Sales” to see the city-wise result.

This is absolutely giving us blunder results because it is adding overall value for all the cities in each row so this is the wrong way of applying SUMX function in Power BI.

#### SUMX in Power BI – Example #2

For the same table, we will do additional calculations. For example assume for every transaction we are going to deduct 5% as the handling charges.

- Right-click on the table and choose “New Measure” and give the name as “Sales after Charges”.
- Enter the below formula now.

- Click on Enter key we will have the new measure.
- Drag and drop the measure to the table to see the difference.

As you can see now we have Sale Value before deducting charges and “Sale after Charges” (SAC). For example for Mumbai “Sale Vale” was 17016 after deducting 5% charges it is 16165. i.e. Mumbai = 17016 – (17016 * 5/100) = 16165.

#### SUMX in Power BI – Example #3

Now we will see nested calculations. For example assume wherever the city name is “Bangalore” we are going to give an additional 500 rupees discount, if not Bangalore discount will be zero.

- So now we need to find out what is the “Sale After Discount” (SDA).
- Apply below measure to find the SAD.

Let me explain you the formula in detail.

- In the “Sales Table”, If the City is “Bangalore” then we need to deduct 500 from Sales After Charges (SAC) or else we need the result as same as Sale After Charge (SAC) only.
- Now drag and drop the new measure to the existing table to see the difference.

- As you can see above only for “Bangalore” city sales amount has been changed and for other cities, it remains the same as then left column i.e. SAC Value.

**Note:** To apply conditional formatting we need data, you can download the Power BI file to get the ready table.

### Things to Remember

- SUMX function in power BI is used to calculate row by row calculations.
- SUMX do the calculation as per the equation provided for Expression.
- Each row will be affected by the SUMX function.

### Recommended Articles

This has been a guide to SUMX in Power BI. Here we discuss how to use SUMX Function in Power BI along with examples and downloadable excel templates. You can learn more about Power BI form the following articles –

- Types of Power BI Filters
- Power BI GroupBy
- Power BI Conditional Formatting Examples
- Power BI Icons Sets

- 6 Online Courses
- 29+ Hours
- Verifiable Certificate of Completion
- Lifetime Access