TIL: SAQL windowing for running totals
On this page
A running total in SAQL is just a windowing function over an ordered grouping:
q = load "opportunities";
q = group q by 'CloseMonth';
q = foreach q generate 'CloseMonth' as 'Month',
sum('Amount') as 'Amount',
sum(sum('Amount')) over ([..0] partition by all order by 'CloseMonth') as 'Running';
The [..0] frame means “from the start of the partition up to the current row” — that’s
what produces the cumulative sum. Swap partition by all for a real field to reset the
total per segment.