Two Column Lookup

爷,独闯天下 提交于 2019-12-13 07:58:50

问题


I have a data set that I want to return an indexed column using two values: a year and a name. Both these values are formatted to general (I also tried text) in my spreadsheet.

In one work sheet I have a like of people:

On the other, I have a table of Years, Names, and a number

I am trying to do a lookup on the joined year and name and return the given number in the second table. For instance 2013Andrew McCutchen would return 8.2, and 2014Andrew McCutchen would return 6.8.

Currently, I only get the #N/a value with the following"

 =INDEX('2006 Results'!C2:C556,MATCH($J$1&C3,'2006 Results'!$A$2&$B$556,0))

But, I know a certain value is in the table though because I have tested with an if statement to make sure my spelling is correct. Any guidance would be much appreciated.


回答1:


In your match expression, you are comparing one concatenated value $J$1&C3 to another single concatenated value '2006 Results'!$A$2&$B$556. Match expects that second parameter to be a range rather than a single value.

In cases like this, where multiple criteria are required, I prefer to use sumifs rather than index-match, even though the intention is to return a single value. I think =SUMIFS('2006 Results'!$C:$C,'2006 Results'!$A:$A,j$1,'2006 Results'!$B:$B,$c3) will give what you need and should correctly copy to the other cells in that table.




回答2:


I would add a column to the left of the year column as column A to contain the following formula in cell A2 which refers to the year and name column:

=$B2&$C2

You can then use this column in a VLOOKUP formula on the people sheet. Cell J3 would read as follows. Copy this to all cells in the table body.

=VLOOKUP(J$1&$C3,'TheYearSheet'!$A$1:$D$556,4,false)

Job done.



来源:https://stackoverflow.com/questions/28890319/two-column-lookup

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