Search code examples
excelsumifs

EXCEL: Sum columns based on common index


I'm trying to sum columns that have a common index but the difficulty is that the index is not in the same row.

Here is an example

DayIndex2018  Value2018   DayIndex2017   Value 2017
empty           empty         1             20
1                50           2             45
2                60           3             55
3                70           4             33
4                32           5             23

What I would like is to have the sum of "value 2017" for indexes that are in common with indexes for 2018: 20 + 45 + 55 + 33

I though of doing this with a sumif but rows need to be perfectly aligned.

Any idea of how I could do this?

Thanks


Solution

  • Use sumproduct to sum the array of sumif

    Formula in cell F2:

    =SUMPRODUCT(SUMIF(C2:C6,A2:A6,D2:D6))
    

    enter image description here