Please note javascript is required for full website functionality.

Blog

Power Query: Selective Staffing Part 7

8 December 2021

Welcome to our Power Query blog. This week I look at an example that considers values that can be marked as included or excluded.

Last week, I was looking at an example where I had a table of quote data for each of my salespeople, and a list of salespeople that I wished to view quote details for:

I used an Inner Join to merge the data to get the solution:

This time, I will look at how I can expand this to allow me to consider inclusion and exclusion in the same example. To begin with, I will consider the following situation:

I begin in exactly the same way as last week, by extracting the tables to Power Query using ‘From Table/Range’ in the ‘Get & Transform’ section of the Data tab.

The quote data is in table Staff_Quotes_Join_E:

The staff to be excluded are in table Quote_Selection_Join_E:

I can exclude these values by performing a join. I do this from ‘Merge Queries from the Home tab.

This time, I will use a Left Anti Join, which will show me the rows that are only in Staff_Quotes_Join_E and NOT in Quote_Selection_Join_E. I need to specify the columns to compare:

This sounds exactly like what I need, so I click OK.

I can delete the Quote_Selection_Join_E column to get the data I need:

Now I will consider the situation where we have a list staff that are marked as included or excluded.

This time, I am linking to a table that includes all the salespeople, and they have a flag next to their name. I extract the new data into a table called Quote_Selection_Both:

I can still solve this with a merge, but I need an extra row in Staff_Quotes_Join_E:

This highly complicated column always has the value “I” and will simply allow me to merge with Quote_Selection_Both.

I have used an Inner Join to keep the rows I need:

I can now delete Include and Quote_Selection_Both to get the data I need:

Come back next time for more ways to use Power Query!

Newsletter