How to compare two lists and extract similarities or differences in Excel
How to compare two lists and extract similarities or differences in Excel:Suppose you have two very long lists and need to compare the similarities and differences between them. How do you know which elements in the first list do not appear or are present in the second list or vice versa? In this article, Buffcom.net will guide you on how to use the COUNTIF function to compare two lists and extract similarities or differences in Excel.
For example, let’s say we have two lists as shown below. The requirement is to compare which values in list 2 are in list 1. In this case, we can use the COUNTIF function to compare the two lists as follows.
1. COUNTIF function structure
Function syntax: =COUNTIF(Range; Criteria)
- Range: is the data range of cells you want to count
- Criteria: is the condition for a cell to be counted
Note: The COUNTIF function applies only to one condition.
2. How to use the COUNTIF function to compare two lists
Applying the COUNTIF function structure above, we have the formula in cell C2 as follows:
- $A$2:$A$10 is the range of list 1 to compare with
- B2 is the value to compare in list 2
Copying the formula for the remaining cells in column C, we will get the results as shown below.
- A result of 0 means the value in list 2 is not in list 1
- A result of 1 means the value in list 2 is in list 1
Next, we will proceed to extract the values by selecting the Data tab on the toolbar. Then click on the Filter icon under the Sort & Filter section.
Now, the Filter icon will appear at the top of the columns in the table. Click on the Filter icon at cell C1. Then filter the results as follows:
- To filter the content that appears in both lists, filter the values with a result of 1
- To filter the content that is only in list 2, not in list 1, filter the values with a result of 0
Thus, the article has guided you on how to use the COUNTIF function to compare two lists and extract similarities or differences in Excel. Hopefully, this article will be useful to you in your work. Good luck!