Cumulative column in script using loop

Hello,

I am trying to create a table of products with a cumulative volume column. I have done this in my script successfully for the entire loaded data set, but now need to modify my script to account for multiple markets. The cumulative volume column should be per market, not based on overall volume.

This is my script so far, though I am struggling with the correct syntax for the loop (red font below), please can anyone advise?