I am having trouble using INDEX and MATCH functions in excel. Say I have the following data:
A B C D
Year Month Site Count
2004 3 X1 54
2006 6 X3 10
2005 10 X5 15
And I want to arrange it like this
E F G H I J K
Year Month X1 X2 X3 X4 X5
2004 1
2004 2
2004 3 54
2004 4
2004 5
2004 6
...
2005 10 10
...
2006 6 15
I have the following formula (I want to match the Site, Year and Month):
=IFERROR(INDEX($D$2:$D$4,MATCH(G$1,$C$2:$C$4,0),MATCH($E2,$A$2:$A$4,0),MATCH($F2,$B$2:$B$4,0)),"")
and it seems to work fine for the first column (G) but when I autofill the rest of the columns (H:K) it doesn't work. Any ideas? Thanks.
I'd take a different approach than using all these nested matches, and create a searchable column with unique values and MATCH
that column to get a row to feed into the INDEX
.
Insert 2 rows between Cols D and E, putting the 2nd appearance of 'Year' in Column G. (Because I like some whitespace)
Paste this formula in E2 and copy it to E3:E4
=CONCATENATE(C2,"-",A2,"-",B2)
If it bothers you, hide Column E.
Then paste this formula in I2 and copy it to I2:M4:
=IFERROR(INDEX($D$2:$D$4,MATCH(CONCATENATE(I$1,"-",$G2,"-",$H2),$E$2:$E$4,0),0),"")
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.