Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
bhaskarsharma03
Creator
Creator

Running total with a condition

Hi,

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.

Regards,

Bhaskar

10 Replies
bhaskarsharma03
Creator
Creator
Author

Considering that I have close to a billion records (if not more), I am trying to minimize the front end calculations as much as I can.