1
votes

I want to get MAX running total. Not just MAX from the column, but max running total updated on each new entry row. And so that it will not overwrite previous entry.

So far I came up with this:

=ArrayFormula(if($C$3:$C="","",MAX("<="&row($C$3:$C),$C$3:$C,A2)))

but it overwrites all the entries above. Giving me just total.

Sample

Here's sample doc.

2

2 Answers

2
votes

You might try, in A2 and copied down to suit:

=max(A1,C$1:C2)
1
votes
=ARRAYFORMULA(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
 {QUERY(QUERY(TRANSPOSE(QUERY(TRANSPOSE({
 QUERY(       Q2:Q,         "limit "&COUNTA(Q2:Q)), 
 QUERY(OFFSET(Q2:Q, -1, 0), "limit "&COUNTA(Q2:Q)-1)}),
 "select "&REGEXREPLACE(JOIN(, IF(LEN(Q2:Q),
 "max(Col"&ROW(Q2:Q)-ROW(Q2)+1&"),", )), ".\z", "")&"")),
 "select Col2"),
 "limit "&COUNTA(Q2:Q)),
 {""; QUERY(TRANSPOSE(QUERY(TRANSPOSE({
 QUERY(       Q2:Q,         "limit "&COUNTA(Q2:Q)),
 QUERY(OFFSET(Q2:Q, -1, 0), "limit "&COUNTA(Q2:Q)-1)}),
 "select "&REGEXREPLACE(JOIN(, IF(LEN(Q2:Q), 
 "max(Col"&ROW(Q2:Q)-ROW(Q2)+1&"),", )), ".\z", "")&"")),
 "select Col2 
  limit "&COUNTA(Q2:Q)-1)}}),
 "select "&REGEXREPLACE(JOIN(, IF(LEN(Q2:Q),
 "max(Col"&ROW(Q2:Q)-ROW(Q2)+1&"),", )), ".\z", "")&"")),
 "select Col2"))