Kevrone
Kevrone

Reputation: 624

How do I sum horizontally across a row based on 1st column value?

I've used the search but haven't found much on this. Essentially I would like to do a SUMIF style action on a dataset but it only grabs the first adjacent value. My table would be something like:

KT    4    5    9
AM    3    7    8
IA    2    5   12

On rows below I would have

KT |  =Sumif(A1:E3,A8,B1:E3)   Which returns 4
AM |  =Sumif(A1:E3,A9,B1:E3)   Which returns 3
IA |  =Sumif(A1:E3,A8,B1:E3)   Which returns 2

Now I know I could surely just add a column with a total use vlookup(array, value, index) but that is not what I want to do (although I may just do so if this is too big a pain).

Any thoughts/ideas. Demo here

Upvotes: 0

Views: 14169

Answers (1)

Jerry
Jerry

Reputation: 71578

Try using INDEX and MATCH to get the 'VLOOKUP` similarity:

=SUM(INDEX($B$1:$E$3, MATCH(A8, $A$1:$A$3, 0), 0))

INDEX($B$1:$E$3, MATCH(A8, $A$1:$A$3, 0), 0) returns the row within $B$1:$E$3 where the range $A$1:$A$3 corresponds to A8.

Upvotes: 2

Related Questions