3 Replies Latest reply: Jun 28, 2018 6:38 AM by Felip Drechsler RSS

    How does Cumulative Sum work with RangeSum and Peek in script editor?

    Piotr Amarowicz

      Hi,

       

      this a bit different question: I found a script showing how to calculate a cumulative sum in load editor using RangeSum() and Peek(). Although I know both these functions I can't understand how they work together and return a proper Cumulative Sum. Can someone explain me how Peek() works as an argument in RangeSum()?

       

      The concept is:

       

      test:

      Load

      date,

      RangeSum(value,Peek(CumulativeSum)) as CumulativeSum

      ;

      Load * Inline [

      date,value

      2018-01-01,10

      2018-01-02,5

      2018-01-03,2

      2018-01-04,7

      ];

       

       

      The output is:

       

      dateCumulativeSum
      2018-01-0110
      2018-01-0215
      2018-01-0317
      2018-01-0424