I needed a per customer rolling average of how late invoices are paid, below was the formula used :
Formula(Numeric) : AVG /* rt */ (NVL({applyingtransaction.trandate}, {today}) - {duedate}) OVER (PARTITION BY {name} ORDER BY {trandate}, {internalid} ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
You can also use SUM as : SUM/* rt */ (NVL({applyingtransaction.trandate}, {today}) - {duedate}) OVER (PARTITION BY {name} ORDER BY {trandate}, {internalid} ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW).