Excel Array formula IF(multiple criteria)

青春壹個敷衍的年華 提交于 2019-12-29 06:32:53

问题


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


回答1:


Typically AND won't work here because AND returns a single result rather than an array....but * should be OK, i.e. 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




回答2:


You can also use a simple formulas:

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

make sure to put the condition between parenthesis.



来源:https://stackoverflow.com/questions/10540719/excel-array-formula-ifmultiple-criteria

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