Excel 2024: Use a Pivot Table to Compare Lists
May 22, 2024 - by Bill Jelen
When you think of comparing lists, you probably think of VLOOKUP
. If you have two lists to compare, you need to add two columns of VLOOKUP
. In the figure below, you are trying to compare Tuesday to Monday and Wednesday to Tuesday and maybe even Wednesday to Monday. It is going to take a lot of VLOOKUP
columns to figure out who was added to and dropped from each list.
You can use pivot tables to make this job far easier. Combine all of your lists into a single list with a new column called Source. In the Source column, identify which list the data came from. Build a pivot table from the combined list, with Name in rows, RSVP in values, and Source in columns. Turn off the Grand Total row, and you have a neat list showing a superset from day to day, as shown below.
Bonus Tip: Show Up/Down Markers
There is a super-obscure way to add up/down markers to a pivot table to indicate an increase or a decrease.
Somewhere outside the pivot table, add columns to show increases or decreases. In the figure below, the difference between I6 and H6 is 3, but you just want to record this as a positive change. Use =SIGN(I6-H6)
to get either +1, 0, or -1.
Select the two-column range showing the sign of the change and then select Home, Conditional Formatting, Icon Sets, 3 Triangles. (I have no idea why Microsoft called this option 3 Triangles, when it is clearly 2 Triangles and a Dash, as shown below.)
With the same range selected, now select Home, Conditional Formatting, Manage Rules, Edit Rule. Check the Show Icon Only checkbox.
With the same range selected, press Ctrl+C to copy. Select the first Tuesday cell in the pivot table. From the Home tab, open the Paste dropdown and choose Linked Picture. Excel pastes a live picture of the icons above the table.
At this point, adjust the column widths of the extra two columns showing the icons so that the icons line up next to the numbers in your pivot table, as shown below.
After seeing this result, I don't really like the thick yellow dash to indicate no change. If you don't like it either, select Home, Conditional Formatting, Manage Rules, Edit. Open the dropdown for the thick yellow dash and choose No Cell Icon, and you get the result shown below.
Bonus Tip: Compare Two Lists by Using Go To Special
This tip is not as robust as using a Pivot Table to Compare Two Lists, but it comes in handy when you have to compare one column to another column.
In the figure below, say that you want to find any changes between column A and column D.
Select the data in A2:A9 and then hold down the Ctrl key while you select the data in D2:D9.
Select, Home, Find & Select, Go To Special. Then, in the Go To Special dialog, choose Row Differences. Click OK.
Only the items in column A that do not match the items in column D are selected. Use a red font to mark these items, as shown below.
Caution: This technique works only for lists that are mostly identical. If you insert one new row near the top of the second list, causing all future rows to be offset by one row, each of those rows is marked as a row difference.
Thanks to Colleen Young for this tip.
This article is an excerpt from MrExcel 2024 Igniting Excel
Title photo by Getty Images on Unsplash