Excel LOOKUP with multiple outcomes

混江龙づ霸主 提交于 2019-12-11 18:42:45

问题


Excel LOOKUP with multiple outcomes

Currently I am using the formula: =LOOKUP("Pending", DK6, A6)

So if the cell contents of DK6 says “Pending” it displays the value from cell A6.

I need to add some more clauses and would appreciate some help on how to construct the formula. The logic I am looking for is as follows…

LOOKUP("Pending", DK6, A6) > ?ELSEIF? > LOOKUP(“Delegated”, DK6, leave cell blank) > ?ELSEIF? > LOOKUP(“Rejected”, DK6, leave cell blank) > ?ELSEIF? > LOOKUP(blank cell, DK6, leave cell blank)


回答1:


To get lists of multiple matching rows you can apply SMALLL() to pick up the first, second, third, etc. value.

          

The formula in DL2 is,

=IFERROR(INDEX($A$2:$A$99, SMALL(INDEX(ROW($1:$98)+($DK$2:$DK$99<>"Pending")*1E+99,,),ROW(1:1))),"")
  ... or,
=IFERROR(INDEX($A$2:$A$99, SMALL(INDEX(ROW($1:$98)+($DK$2:$DK$99<>DL$1)*1E+99,,),ROW(1:1))),"")

To gather cells in column A where column DK is blank is a little different.

=IFERROR(INDEX($A$2:$A$99, SMALL(INDEX(ROW($1:$98)+(($A$2:$A$99="")+($DK$2:$DK$99<>""))*1E+99,,),ROW(1:1))),"")

These formulas seem to be a better fit than the array formulas provided in another thread. The values in column A are by nature unique so that does not have to be compensated for.




回答2:


If you want ELSEIF formulas, you need to nest IF formulas, for example:

=IF(DK6="Pending",A6,IF(DK6="Delegated","",IF(DK6="Rejected","",IF(DK6="",""))))

The logic you gave could be simplified because there's leave cell blank in last three cases, so you could just use:

=IF(DK6="Pending",A6,"")



来源:https://stackoverflow.com/questions/25834652/excel-lookup-with-multiple-outcomes

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