Home > Enterprise >  Calculate the Sum of same rows from different columns using Excel formula
Calculate the Sum of same rows from different columns using Excel formula

Time:01-19

My actual data belong to Column G to N, where I've Name and quarter columns. Column A contains 2 quarters and I want to calculate VAL1 and VAL2.

enter image description here

Logic to create VAL1:

  • for 2021Q2, identify all the non-zero Names from Column M (2021Q2) then SUM values of (M,L,K) for the same Names.
  • for 2021Q3, identify all the non-zero Names from Column N (2021Q3) then UM values of (N,M,L) for the same Names.

Logic to create VAL2:

  • for 2021Q2, identify all the non-zero Names from Column M (2021Q2) then SUM values of (J,I,H) for the same Names.
  • for 2021Q3, identify all the non-zero Names from Column N (2021Q3) then UM values of (K,J,I) for the same Names.

I've tried few approaches, like identify the location using ADDRESS(MATCH), getting ROW numbers, but didn't work properly. Can anyone please help with a formula to get the desired values?

CodePudding user response:

1] In B2, formula copied down :

=SUMPRODUCT((OFFSET($G$2,0,MATCH($A2,$H$1:$N$1,0),7)<>0)*OFFSET($G$2,0,MATCH($A2,$H$1:$N$1,0),7,-3))

2] In C2, formula copied down :

=SUMPRODUCT((OFFSET($G$2,0,MATCH($A2,$H$1:$N$1,0),7)<>0)*OFFSET($G$2,0,MATCH($A2,$H$1:$N$1,0)-3,7,-3))

enter image description here

  •  Tags:  
  • Related