How to return row value that meets two criteria in Excel

不问归期 提交于 2019-12-24 05:12:03

问题


I have an excel spreadsheet to keep track of project activities.

In Column A I have the Project Name and it repeats several times because the same project has several activities.

In Column B I have the Activities related to that project.

In Column C I have the % Complete of each activity.

What I would like to accomplish is: in Column D return the first Activity of the Project that is not 100%.

Here is a picture of what I would like to accomplish:

I was trying this formula with no luck:

=INDEX($B$2:$B$19,MATCH(TRUE,INDEX($C$2:$C$19<>100%,),0))

Then I found this one posted here:

Return smallest unique value that meets criteria

and here:

multiple criteria small function excel

But I haven't been able to get them to do what I want. Any help would be much appreciated.

Thanks


回答1:


For what it's worth, here is a slightly more accurate formula than @AlexisOlson's:

=INDEX($B$2:$B$19,MATCH(1,($A$1:$A$19=A2)*($C$1:$C$19<>1),0))

Typically, it is not a good idea to have concatenations within MATCH because it may lead to incorrect results.

For example:

= MATCH("12"&"34",{"1","12"}&{"234","34"},0)

This formula would return 1 when you would actually want it to return 2.

Changing to this:

= MATCH(1,({"1","12"}="12")*({"234","34"}="34"),0)

Will remove any risk of falsely picking the wrong lookup values.

Of course, in this particular case, it makes no difference, because there is no possible way that $C$1:$C$19<>1 could return anything other than TRUE or FALSE, but it is just something to be aware of.

The only time I will use the & approach inside MATCH is if I actually desire to find the concatenation of strings in a single range, e.g. something like:

= MATCH("John"&" "&"Doe",{"John Doe","Bill Miller","Mike Jones"})



回答2:


You need to match on two conditions, the Project and the percent:

=INDEX($B$2:$B$19, MATCH(A2&TRUE, $A$1:$A$19&($C$1:$C$19 <> 1), 0))

This needs to be entered as an array formula using Ctrl+Shift+Enter in the formula box.



来源:https://stackoverflow.com/questions/48811811/how-to-return-row-value-that-meets-two-criteria-in-excel

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