How to perform calculation with cumulative sum using ARRAYFORMULA

Viewed 972

Is it possible to perform an arbitrary calculation (eg. A2*B2) on a set of rows and obtain the cumulative sum along the way using ARRAYFORMULA? For example, in the following sheet we have numbers (column A), multipliers (column B), the result of multiplying them (column C), and a cumulative tally (column D):

  | A       B           C       D           E                F
-------------------------------------------------------------------------------
1 | number  multiplier  result  cumulative  array formula    array formula sum?
2 | 3       4           12      12          12  
3 | 2       4           8       20          8   
4 | 10      1           10      30          10  
5 | 7       9           63      93          63  

I can use ARRAYFORMULA in cell E2 (specifically, ARRAYFORMULA(A2:A5*B2:B5)) to do the multiplication. Is it possible to use ARRAYFORMULA (or alternative tool) in cell F2 to show the cumulative total?

1 Answers

use:

=ARRAYFORMULA(IF(A2:A="",,MMULT(TRANSPOSE((ROW(A2:A)<=
 TRANSPOSE(ROW(A2:A)))*A2:A*B2:B), SIGN(B2:B))))

0

Related