I am trying to calculate running total based on a condition. In the attached sample file, I have taken a sample data for one Customer and one Company. What I want to check is if the Balance for one period is equal (or close) to the sales. If not then add the sales of previous period and continue till the cumulative sales is close to (but doesn't exceed) the Balance.
Here is one example for April (201804):
1. Is April Balance equal to April Sales?
2. If it is less, then compare April+March Sales with April Balance
3. If still less, then compare April+March+Feb Sales with April Balance
4. Continue till the running Sales total exceeds the Balance, and then take the running total of previous step (as that is the closest but not greater than the April Balance)
Thanks in advance for your help.