简体   繁体   中英

Excel Array formula IF(multiple criteria)

In my spreadsheet, comparing headphones, our instruction is basically to use as many different formulas as possible.

So as part of the spreadsheet, I would like to be able to show the most expensive headphones per manufacturer , cheapest per manufacturer, best rated per manufacturer etc... So far I have been able to get some mostly working array formulas.

For example, this formula works to get the model of the manufacturer "Sennheiser" with the highest price:

=INDEX($Data.$B$5:$L$32,SMALL(IF($Data.$E$5:$E$32 = $Sheet2.D17, ROW($Data.$B$5:$E$32) - ROW($Data.$B$5) + 1, ROW($Data.$E$32) + 1), 1), 2)

Column E is the Price column and D17 is a pre-calculated Max price for "sennheiser"

This works fine, until you get 2 headphones with the same price / rating or whatever. THen it starts returning the wrong values.

So I tried various solutions that I found on the interwebs, like

AND(condition1, condition2) 
condition1 * AND(cndition2)
condition1 * condition2

but none of this seems to work with an array formula for some reason. I get #N/A or #VALUE and various other errors. SO basically I would like to know how to modify my formula, or even a completely new formula, to check for lowest price AND the correct manufacturer.

I hope my question is clear, so I have uploaded the spreadsheet to get some idea of what I am talking about.

http://dl.dropbox.com/u/18816338/Stats%20Analysis%20%20%281%29.xlsm

Thanks in advance

You can also use a simple formulas:

=if( (Condition_A) * (Condition_B) * ... ; true; false)

make sure to put the condition between parenthesis.

Typically AND won't work here because AND returns a single result rather than an array....but * should be OK, ie try this formula in B3

=INDEX(Data!C$5:C$32,MATCH(1,(Data!$E$5:$E$32=$D3)*(Data!$B$5:$B$32=$A3),0))

confirmed with CTRL+SHIFT+ENTER and copied to C3 and then down both columns

That will find the first match for both price and manufacturer and return the relevant model/type

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