Search code examples
arraysgoogle-sheetssumgoogle-sheets-formulaarray-formulas

How to Subtract 2 Arrays and Sum the difference in one Cell?


This is an example of what i want to achieve; So i have two arrays need to subtract them and check if the array in the right has all the values if not i don't want to subtract the empty cell with the correspondig cell in the other array (example {B3-D3}) and i want to add the sum of all the differences in A5. My previous solution was to do on column E

E1=ifnumber(D1),B1-D1 
E2=ifnumber(D2),B2-D2 
E3=ifnumber(D3),B3-D3 
E4=ifnumber(D4),B4-D4

But I'm looking for something more elegant that shows the result using only one cell in this case A5

Example


Solution

  • In A5:

    =SUM(FILTER(ABS(B1:B4-D1:D4),ISNUMBER(D1:D4)))