Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
nguyenviethung
Contributor III
Contributor III

How to distinct count cumulative with date ranges

Hi experts,

I got data like this table:

Outlet IDDateSalesOrder status
11111/1/201710Approved
11211/1/201720Rejected
11311/1/201730Rejected
11111/1/201790Rejected
11811/1/2017120Approved
11111/4/201740Approved
11311/4/201760Approved
11511/4/2017100Approved
11711/4/2017110Rejected
11911/4/2017130Rejected
11211/5/201750Rejected
11411/5/201770Approved
11511/6/201780Approved
11211/7/201750Approved
11411/7/201770Rejected

I want to count cumulative outlets by date like this:

DateCount distinct Outlet ID with total sales >=45, order status ="approved"Count cumulative Outlet with sales >=45 and order status ="approved"
11/1/201711
11/4/201724
11/5/201715
11/6/201715
11/7/201716
Grand Total66

Can anyone help me the expression for the two ways of counting outlet ID, especially the second count which means Total cumulative outlets with sales >=45 and sales order status must be "approved" only.

Thank you a lot from Vietnam.

22 Replies
sunny_talwar

How far do you plan to accumulate? for a month? for a year? accumulate without end? It depends on what you need finally, because I don't think there is a front end solution (or at least it is not going to be a simple or efficient one). But you can def. try to improve performance of AsOfTable if you don't have to do the while loop till the very end.

sunny_talwar

nguyenviethung‌ I wouldn't close the thread if you don't have an optimum solution. May be someone else have better ideas, especially swuehl‌ might be able to contribute in some way.

Best,

Sunny

nguyenviethung
Contributor III
Contributor III
Author

I want to calculate by week and my sales data for this year has reached around 4mil rows. Perhaps you're correct, QS hasnt provided any front-end solution for this complicated case.