Count apple based on common ID between two tables

南笙酒味 提交于 2021-01-29 14:12:02

问题


I have two Excel tables that look like this:

Table 1

 A          B         C 
ID    Stocked      Sale
1       shelf      sold
5     display      sold
9       shelf      sold
12      shelf      sold
13      shelf

Table 2

 P          Q 
ID    Stocked
a2      apple
88
83
1       apple
9       apple

I need to count the total number of apples by common ID, given that apples are:

  • stocked on the shelf in Table 1
  • sold in Table 1

So, the outcome has to be 2 apples.

Here is what I have tried thus far:

COUNTIFS(B:B, "shelf", C:C, "sold", Q:Q, "apple")

I can't figure out how to count by common id...


回答1:


Something like this should work for you:

=SUMPRODUCT(COUNTIFS(A:A,REPT($P$2:$P$6,$Q$2:$Q$6="apple"),B:B,"shelf",C:C,"sold"))


来源:https://stackoverflow.com/questions/59951678/count-apple-based-on-common-id-between-two-tables

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