Google Sheets: Compare Two Lists and Extract Differences

You can use the FILTER function with COUNTIF or ISNA+MATCH to compare two lists and extract the differences in Google Sheets.

You can compare List 1 with List 2 to extract the items in List 1 that are not available in List 2 and vice versa.

For example, I have received a quotation from a vendor for plumbing materials. Their quotation is based on the availability of materials with them. Now, I can compare this list with my requirements in two different ways:

  1. I can compare the list provided by the vendor with my original requirements and find the unavailable items.
  2. I can also find the items in the vendor’s list that do not match my requirements.

Compare Two Lists and Extract Differences: Understanding the Scenario

My requirements are listed in column A (A2:A), and what the vendor offered (quoted) is listed in column B (B2:B).

RequirementOffered by VendorItems Not Available with the VendorAdditional Items Offered
Copper PipesUPVC PipesCopper PipesHealth Faucets
UPVC PipesHealth FaucetsBrass FittingsWater Heaters
Brass FittingsShower HeadsDrain PipesConcealed Valve
Drain PipesWater Heaters
Shower HeadsWater Filters
Water FiltersConcealed Valve

Since it’s a small list, you can manually find the items that are not in the offered list, but it’s not feasible for larger requirements. This is where formulas become helpful.

With the help of a custom Google Sheets formula, I’ve found those items in column C (C2:C).

In column D, I have listed the additional items that the vendor offered (quoted), which are not in my original requirements in column A.

In Google Sheets, you can easily compare two lists and extract the differences as shown above.

Compare Column A with Column B and Extract Non-Present Items

This is useful for finding items you want but are unavailable from the vendor. Your items are in column A, and the items available from the vendor are in column B.

As mentioned, you can use either FILTER with COUNTIF or FILTER with ISNA+MATCH. Here are both solutions:

You can try the following formulas in cell C2:

Solution 1:

=FILTER(A2:A, ISNA(MATCH(A2:A, B2:B, 0)))
Compare List 1 with List 2 and Extract Non-matching List 1 Items

The FILTER function filters A2:A based on the condition ISNA(MATCH(A2:A, B2:B, 0)).

What does this condition mean?

The MATCH function searches for the values in A2:A within B2:B and returns the relative positions of matching items or #N/A for items not found. ISNA returns TRUE for #N/A and FALSE for relative positions (matches).

The FILTER function filters rows where the condition is TRUE.

Solution 2:

=FILTER(A2:A, COUNTIF(B2:B, A2:A)=0)

Here, the condition is COUNTIF(B2:B, A2:A)=0.

The COUNTIF function counts how many times each value in A2:A appears in B2:B. If it returns 0, it means that the value is not present in B2:B.

This allows you to compare two lists and extract the differences, or in other words, the non-matching items in List 1.

Compare Column B with Column A and Extract Non-Present Items

To compare column B values with column A values and extract the differences in column B, you can use the formulas above by swapping the ranges. These are useful for identifying items offered by the vendor that are not in your list.

Solution 1:

=FILTER(B2:B, ISNA(MATCH(B2:B, A2:A, 0)))
Compare List 2 with List 1 and Extract Non-matching List 2 Items

Solution 2:

=FILTER(B2:B, COUNTIF(A2:A, B2:B)=0)

Here, the FILTER formula filters B2:B based on the given conditions.

This way, we can compare two lists and extract the differences in Google Sheets.

Resources

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

How to Create a Searchable Table in Excel Using the FILTER Function

Finding specific records, or rows containing the required information, is straightforward in Excel using...

Time Sequences in Excel by Minute, Hour, or Second Increments

Creating time sequences, whether by hour, minute, or second increments in Excel, can be...

Finding Most Frequent Text in Excel with Dynamic Array Formulas

Looking to identify the most frequently occurring text in Excel? You can do this...

Hierarchical Numbering Sequences in Excel

Creating hierarchical numbering sequences in an Excel spreadsheet can significantly improve the way you...

More like this

XMATCH Row by Row: Finding Values Across a Range in Google Sheets

Using the BYROW function with XMATCH in Google Sheets allows us to match values...

Limit Formula Expansion to a Specific Row in Google Sheets

In this tutorial, I’ll explain how to limit the expansion of an array formula...

3-D Referencing Structured Data Tables in Google Sheets

When you have several tables within a single sheet—not across multiple sheets in a...

6 COMMENTS

  1. Hey, Thank you.
    What if the item repeats?
    Say, for example, Item 6 is twice in column A and only once in column B.

  2. Great article, helped me a lot!

    But although I could do what I intended in my project, I still don’t understand one thing. Could you explain this or direct me to some reading that does?

    In the formula: =sort(if(COUNTIF(A2:A,B2:B)=0,B2:B,))

    The IF returns blank if there is a difference and it is false, doesn’t it?

    Then the SORT returns the list of values that are different. I don’t understand how the SORT function gets these values or what the IF is actually returning as value_if_false.

    • Hi, gustavo,

      To understand the logic, please make a table as per my example (cell range A1:B7).

      Then in cell H2, insert the below Countif.

      =ArrayFormula(COUNTIF(A2:A10,B2:B10))

      Note:- You won’t see ArrayFormula use in my original formula. I’ll come to that below.

      You can see that it returns the numbers 1 and 0 (against B2:B10). The number 1 for the match and 0 for the mismatch.

      The logical_expression in IF is ArrayFormula(COUNTIF(A2:A10,B2:B10))=0

      value_if_true – return values from B2:B10
      value_if_flase – return blank

      The SORT plays two roles.
      1. It’s an alternative to the above ArrayFormula use. So COUNTIF works without any issue in a cell range.
      2. The second one is most important. Without SORT, you may have blanks between the values in the IF result. By sorting, we can solve it.

  3. This is a great help, thanks for the info. Could you help with how to get the count of the number of items in column A which are not present in Column B?

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.