KEY is main dimension
Month is time dimension
1.for each KEY, if Month is past month then wanted result is 0
2.for each KEY, if Month is equal or larger than current month, then depending on Balance value (<0 or >=0) to use different calculation way (details in attached file)
most hard part to me is using cumulative value of above rows as a input for next row, in excel it's easy.
TB07_20170809_154247.xlsx 12.3 K