简体   繁体   中英

Excel arrays count totals using criterias from multiple ranges (or sheets)

What I would like to do is to count the amount of lines that matches criterias to be verified in two arrays. I can't use VBA, add new columns (for instance a new column with VLOOKUP formula) and preferably use arrays.

I have two separate ranges, each with a ID column for the identifier and other fields with data.

For instance, range 1:

在此处输入图片说明

Range 2:

在此处输入图片说明

If I had only to check the first range I would do:

={SUM((D4:D7="Red") * (E4:E7="Big"))}

But I don't know how to check also using data from the other range.

How, for example, to count the number of items that are Red, Big and Round by using both Ranges ?

Put this in the cell F4:

=IF((VLOOKUP(C4,$C$11:$D$12,2)="Round")*(D4="Red")*(E4="Big"),1,"")

Note that the behavior of VLOOKUP is that it finds the value up to the first parameter. Since there's no 1 in your second dataset, this first cell is going to show "#N/A", which I don't know how to solve, but when you extend this formula down to also compare the other sample data in the first set, the ID numbers 2 and 4 will show up as "yes" for you.

Edit: You wanted a count of this list. So after this, it should be easy to get a count of cells in this column using the COUNT function.

Try this array formula

=SUM((D4:D7="Red")*(E4:E7="Big")*ISNUMBER(MATCH(C4:C7,IF(D12:D13="Round",C12:C13),0)))

The last part is the added criterion you want - the IF function returns {2,4} [IDs where Data 3 is "Round"] and then you can use MATCH to compare C4:C7 against that. If there is a match you get a NUMBER (instead of #N/A) so you can then use ISNUMBER to get TRUE/FALSE and that feeds in to your original formula - result should be 2

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