ID MONTH USD CUM_TOT X D 1 12 12 1 ok D 2 5 17 3 no should be 4! D 3 3 20 3 no! should be 4 see the problem? the cum_tot is 20 and so it get flagged but it shouldnt! first invoice was at 12, here we're at 8 (5+3) it shouldnt! D 4 4 24 6 should be 4, because here 5+3+4 we surpass the threshold D 5 2 26 6 ok D 6 8 34 6 ok E 1 38,2 38,2 1 ok E 2 9,9 48,1 2 see? its < 10, it does not surpass 10, but since before we had 38.2 which is way higher than 10 it keeps flagging as surpasses. that should be 3 E 3 9,2 57,3 3 ok E 4 7,4 64,7 4 we have still the same problem E 5 2,7 67,4 6 E 6 8,6 76 6