Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calculate Cumulative Sales in Script

Hi

I am trying to get the cumulative sales per Booking Date per Service Month.

Please see below...

Service MonthBooking DateSalesCumulative Sales
Jul-142014-01-15851851
Jul-142014-02-01100951
Jul-142014-04-101501101
Jul-142014-07-152921393
Jul-142014-07-183561749
Aug-142014-03-23659659
Aug-142014-08-237841443
Aug-142014-08-252541697
Aug-142014-08-281691866
Sep-142014-04-193232
Sep-142014-05-12524556
Sep-142014-05-2894650
Sep-142014-08-098631513
Sep-142014-09-21971610
Oct-142014-10-01899899
Oct-142014-10-139661865
Oct-142014-10-164442309

I am trying to get field 'Cumulative Sales' ..

Any suggestions will be appreciated.

Regards,

Magen

4 Replies
Not applicable
Author

Hi,

try this it would be helpful to you

Load *,numsum(Sales+peek([Cumm Sales]) as [Cumm Sales]

resident Table;

maxgro
MVP
MVP

tmp:

LOAD [Service Month], date(date#([Booking Date],'YYYY-MM-DD')) as [Booking Date], Sales, [Cumulative Sales]

FROM [http://community.qlik.com/thread/139744] (html, codepage is 1252, embedded labels, table is @1);

final:

load

  *,

  if(peek([Service Month])<>[Service Month], Sales, Sales + peek(NewCumSales)) as NewCumSales

Resident tmp

order by [Service Month], [Booking Date];

DROP Table tmp;

ashfaq_haseeb
Champion III
Champion III

Hi,

Check for my solution in the below link.

http://community.qlik.com/thread/139746

Regards

ASHFAQ

anbu1984
Master III
Master III