how do I find the values that are in one column but not in the other

我只是一个虾纸丫 提交于 2021-02-06 08:32:32

问题


I have two columns A and B in a google spreadsheet.

I want to find all the numbers that are in column A but not in B. How do I do that?

B could have the same numbers from column A.

So if column A has numbers: 1, 2, 3 and B has numbers 3, 4,5

I want to get all the numbers that are in A but not in B: 1, 2

How do I do that using google spread sheet?


回答1:


Use MATCH to determine whether each row in column A appears in column B, then filter column A to only the rows for which MATCH returned #N/A (i.e., that row's value in column A could not be found in column B):

=FILTER(A:A, ISNA(MATCH(A:A, B:B, 0)))

If A contains duplicates and you want to reduce the result sequence to unique values, just wrap the whole thing in UNIQUE:

=UNIQUE(FILTER(A:A, ISNA(MATCH(A:A, B:B, 0))))



回答2:


Based on Kate aswer I have been able to negate not only one column, but several.

Kate solution was as follows:

=FILTER(A:A, ISNA(MATCH(A:A, B:B, 0)))

Where "B:B" is defining that what is going to be returned is A:A less B:B.

But if you want to return A:A, lees B:B, less C:C, less D:D, etc? Just insert B:B, C:C and D:D inside {}, then:

=FILTER(A:A; ISNA(MATCH(A:A; {B:B;C:C;D:D}; 0)))

I hope this may help others like me. I was seeking for a solution that would not bring what's present in some set of columns.

Thanks!




回答3:


In column C, use vlookup from A against B. For example

C1 = vlookup(A1,B:B,1)
C2 = vlookup(A2,B:B,1)
...

If B does not contain A, then it shows #N/A



来源:https://stackoverflow.com/questions/24442475/how-do-i-find-the-values-that-are-in-one-column-but-not-in-the-other

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!