# Power BI: Calculate Difference Between Two Columns in Table

Often you may want to calculate the difference between two columns in a table in Power BI, such as the following table in which we calculate the difference between the Sum of Points and Sum of Assists columns:

Fortunately this is easy to do by creating a measure in DAX and then adding that measure as a column in the table.

The following example shows how to do so in practice.

## Example: How to Calculate Difference Between Two Columns in Table in Power BI

Suppose we have the following table in Power BI named my_data that contains information about various basketball players:

Suppose we insert the following table into a report that shows the sum of points and sum of assists for each team:

Now suppose that we would like to add a new column that shows the difference between the Sum of Points and Sum of Assists columns in the table.

To do so, right click on the my_data table under the Data tab, then click New measure:

Then type the following formula into the formula bar:

`Difference = SUM(my_data[Points]) - SUM(my_data[Assists])`

This will create a new measure that calculates the difference between the Sum of Points and Sum of Assists columns in the table:

Lastly, we can add this new measure named Difference as a column in our table:

This new column will contain the difference between the Sum of Points and Sum of Assists columns in the table:

From the output we can see:

• The difference between points and assists for the Hornets is 31 – 10 = 21.
• The difference between points and assists for the Mavs is 75 – 21 = 54.
• The difference between points and assists for the Rockets is 48 – 12 = 36.
• The difference between points and assists for the Spurs is 65 – 18 = 47.