How do you perform an Anti Join in Power BI and can you provide an example?

An Anti Join in Power BI is a data manipulation technique used to identify and remove all records from one dataset that do not have a matching value in another dataset. This is helpful for finding and highlighting data discrepancies or outliers between two datasets. To perform an Anti Join in Power BI, you can use the “Merge Queries” function and select “Anti” as the join type. This will create a new dataset with only the unmatched records from the first dataset. For example, if you have two datasets – one containing customer information and the other containing sales data – you can use an Anti Join to find all customers who have not made any purchases. This can help identify potential areas for improvement in sales and customer engagement.

Perform an Anti Join in Power BI (With Example)


An anti join allows you to return all rows in one table that do not have matching values in another table.

The easiest way to perform an anti join between two tables in Power BI is to use the Merge Queries function in the Power Query Editor.

The following example shows how to do so in practice.

Related:

Example: How to Perform an Anti Join in Power BI

Suppose we have the following table in Power BI named data1 that contains information about the team name and points scored for various basketball players:

And suppose that we have another table named data2 that contains information about the team name and rebounds for various basketball players:

Suppose that we would like to perform an anti join in which we only keep the rows from data1 that do not have matching values in the Team column in the data2 table.

To do so, click the Home tab along the top ribbon, then click the Transform data icon:

This will bring up the Power Query Editor.

Next, click the Merge Queries icon in the Combine group of the Home tab.

Then click Merge Queries as New from the dropdown menu:

Then click the header for the Team column in each table so that Power BI knows to use those columns for the join:

Once you click OK, the anti join will be performed:

Next, click the left and right arrows on the header of the data2 column. Then check the box next to Rebounds to indicate that this column should be the only one included from data2 in the final merged table:

Once you click OK, the Rebounds column will be shown from the data2 table:

Once you exit out of the Power Query Editor, a message box will appear that asks if you’d like to apply your changes.

Click Yes.

You will then be able to see the new table named Merge1 in the Table view:

Notice that this final merged table contains all rows from the data1 table that did not have matching values in the Team column of the data2 table.

Note: If you’d like, you can right click on the header named data2.Rebounds and rename the column to just Rebounds.

Additional Resources

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

How to Add Index Column to Table in Power BI

x