That’s fantastic thanks Harsh.
As my actual problem was a bit more complex I ended up looking at one of the other posts and using the sumx - values and addcolumns to get the max of either amounts and then doing a cumulative total on that.
All solved in the end, thanks again.