6 Replies Latest reply: Jan 29, 2016 11:38 AM by Sunny Talwar RSS

    Cumulative Sum in script

    Crystle Stamper

      I have a table that lists Sales from Orders. It has many many variables, like Order Dates and Invoice Dates and other specifics about the Order and Shipping.

       

      I need to get a cumulative sum of the items purchased by the Customer. However I can't seem to get it to work. There are thousands of records, but when I do a Sum(Sales) it outputs only like 4 Invoice Dates (key field) and 4 Sales amounts. When I do the Sum in the tables after loading the Script normally, it adds everything up correctly.

       

      I'm not sure but I think I need RangeSum() and Peek() but I can't make them work.

       

      Here's an Example

       

      SalesTable:

      Load

         CustomerID,

         Item,

         InvoiceDate,

         SalesAmt

      From Sales.qvd;

       

       

      SumSales:

      Load

         CustomerID,

         Item,

         InvoiceDate,

         Sum(SalesAmt)

      Resident SalesTable

      Group By

         CustomerID,

         Item,

         InvoiceDate,

      ;

       

      Drop Table SalesTable