简体   繁体   English

Excel:使用公式(无 VBA)如何检查范围内的元素是否在另一个由索引/匹配定义的数组中

[英]Excel: Using a formula (no VBA) how to check if elements in a range are in another array which is defined by index/match

I'd have another question.我还有一个问题。 The situation is as follows: I have two tables (=formatted Excel tables).情况如下:我有两张表(=格式化的Excel表)。 The situation looks as below.情况如下所示。 I am trying to filter for the $ sales amount (cell E4) of a given sales rep (cell D4).我正在尝试过滤给定销售代表(单元格 D4)的 $ 销售额(单元格 E4)。 I was thinking about using =SUMPRODUCT(IF((Table2[Store ID]=INDEX(Table1[Store ID],MATCH("Marc",Table1[Sales Rep],0),)),1,0)) (as I would have other conditions such as month which are no displayed in my example below), however, that's not giving me the correct value.我正在考虑使用=SUMPRODUCT(IF((Table2[Store ID]=INDEX(Table1[Store ID],MATCH("Marc",Table1[Sales Rep],0),)),1,0)) (如我会有其他条件,例如月份,在下面的示例中没有显示),但是,这并没有给我正确的值。 The index-formula gives me just the first result once it finds "Marc".一旦找到“Marc”,索引公式就会给我第一个结果。

The "correct" result in the example shown would be $121 as Marc accounts for these sales in the store with ID 1.所示示例中的“正确”结果为 121 美元,因为 Marc 将这些销售额计入 ID 为 1 的商店。

How can I overcome this problem?我该如何克服这个问题? Any help would be much appreciated.任何帮助将非常感激。

在此处输入图像描述

Add an additional column [shop ok] with a formula =IF(F7=$D$4,[@[store ID]],0) into Table1, to indicate that this store is under Marc's control.将带有公式=IF(F7=$D$4,[@[store ID]],0)的附加列 [shop ok] 添加到 Table1 中,以指示该商店在 Marc 的控制下。

In E4 insert a formula在 E4 中插入一个公式

=SUMPRODUCT(Table2[Sales]* COUNTIF(Table1[shop ok],Table2[Store ID]))

It's an array formula, so add it using Ctrl+Shift+Enter这是一个数组公式,所以使用 Ctrl+Shift+Enter 添加它

示例图片

didn't manage to avoid adding additional columns, got some errors, so ended up with this solution for now.没有设法避免添加额外的列,出现了一些错误,所以现在结束了这个解决方案。

In E4 , enter formula:E4中,输入公式:

=SUMPRODUCT(SUMIFS(I7:I9,H7:H9,D7:D9)*(F7:F9=D4))

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM