How to make a grouped running sum?


I am trying to make grouped running sum to plot inventory level per vendor.

I have a simple dataset :
Date Vendor Qty
1/1 V1 +200
1/1 V2 +50
10/1 V1 -50

I can run the query, but I have not figured how to get the running sums per vendor. Can Metabase do that?
If yes how should I write my question in metabase?


Hi @sbs
I'm not entirely sure if you're just asking to use Sum of Qty grouped by Vendor, or if you are looking to for Cumulative sum of Qty grouped by Vendor and Date.
Both should be possible:


I am looking to achieve au cumulative sum of the quantities across the groups.
Ie with the example above :

1/1 V1 +200
1/1 V2 +50
10/1 V1 +150

And as you stated, you are right, it does work, if I group in the proper order. IE vendor, date, and not in column order as I did :frowning: initially.

So CumSum per group works :slight_smile: thank you


I am coming back on what I said, it looked liked it worked, but now that additional data has been added to the table, it is not working as I need.

I need a running sum of inventory over time per vendor. The running sum groups vendor and date appropriately, but the running sum does not reset.

I need the running sum to be reset to 0 when the vendor group value changes. Like I can get when using sum(qty) over (partition by vendor ordered by date).

Any idea?