简体   繁体   中英

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). The situation looks as below. I am trying to filter for the $ sales amount (cell E4) of a given sales rep (cell D4). 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. The index-formula gives me just the first result once it finds "Marc".

The "correct" result in the example shown would be $121 as Marc accounts for these sales in the store with 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.

In E4 insert a formula

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

It's an array formula, so add it using 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:

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

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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