How can I calculate this conditional monthly limit?
In May client P003 had 600 of buy_amt
(sum of sales in that period) and 1000 transfer_amt
. I want to calculate the remaining limit (buy_amt - transfer_amt
) but starting from top to bottom and the deduction only happens if the result is positive.