How can I compare two columns in Power BI with an example?

In Power BI, the “Compare Columns” feature allows users to easily compare data in two different columns within a dataset. This can be useful for identifying similarities or differences between two sets of data. For example, if a company wants to compare sales data from this year to the previous year, they can use the “Compare Columns” feature to see which products have had the biggest increase or decrease in sales. This can help them make informed business decisions and identify trends within their data.


You can use the following syntax in DAX to create a new column that checks if the values in two columns are equal or not:

Equal = IF('my_data'[Game 1] = 'my_data'[Game 2], "Yes", "No")

This particular example creates a new column named Equal that returns “Yes” if the values in the Game 1 and Game 2 columns are equal or “No” otherwise.

The following example shows how to use this syntax in practice.

Example: How to Compare Two Columns in Power BI

Suppose we have the following table in Power BI named my_data that contains information about points scored by various basketball players in two different games:

Suppose we would like to add a new column that checks if the values in the Game 1 and Game 2 columns are equal in each row.

To do so, click the Table tools tab along the top ribbon, then click the New column icon:

Then type in the following formula into the formula bar:

Equal = IF('my_data'[Game 1] = 'my_data'[Game 2], "Yes", "No")

This will create a new column named Equal that contains either “Yes” or “No” to indicate if the values in the Game 1 and Game 2 columns are equal:

Power BI compare two columns

From the output we can see:

  • The first player had equal values in the Game 1 and Game 2 columns.
  • The second player did not have equal values in the Game 1 and Game 2 columns.
  • The third player did not have equal values in the Game 1 and Game 2 columns.

And so on.

For example, we can use the following syntax to return 1 if two columns have the same value or 0 otherwise:

Equal = IF('my_data'[Game 1] = 'my_data'[Game 2], 1, 0)

This will create a new column named Equal that contains either 1 or 0 to indicate if the values in the Game 1 and Game 2 columns are equal:

Additional Resources

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

x