How do I calculate the difference between two columns in a table using Power BI?

Power BI is a powerful data analysis tool that allows users to easily calculate and analyze data. To calculate the difference between two columns in a table using Power BI, users can follow a simple process. First, they need to select the two columns that they want to compare. Then, they can use the DAX formula “SUBTRACT” to calculate the difference between the values in the selected columns. This will generate a new column with the calculated values. Additionally, users can use other DAX functions such as “SUMX” or “AVERAGE” to perform more complex calculations. With Power BI, users can efficiently and accurately calculate the difference between two columns in a table, providing valuable insights for their data analysis.

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:

Power BI calculate difference between two columns in table

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:

Power BI calculate difference between two columns in 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.

Additional Resources

The following tutorials explain how to perform other common tasks in Power BI:

x