javacumulative-sumactivepivot

How to perfom a cumulative sum that does not rely on level comparators?


We have a cumulative measure that is based on the Stream2PositionPostProcessor (from ActivePivot). We use it to sum on the fly our cach flow along a time dimension.

We want to do the sum in chronological order but display the result in reverse order. To display the result in reverse order we changed the levels comparators.

Here is the pivot table we get:

Time dimension  | cumulative measure
2012            |    20
2011            |    35
2010            |    65
2009            |    75

Here is what we would like to get:

Time dimension  | cumulative measure
2012            |    70
2011            |    55
2010            |    40
2009            |    10

It seems that the Stream2PositionPostProcessor use the level compartors. How can we change this?


Solution

  • If you want to sum on the reverse order, you should set the property "reverseDimensionOrder" to true when defining your stream2position post-processor. (Available since ActivePivot 4.3.0)

    For example:

    <postProcessor pluginKey="Stream2Position">
         <properties>
              <entry key="id" value="CURRENT" />
              <entry key="timeDimensionName" value="BucketRelative" />
              <entry key="streamMeasureName" value="cashFlowInCurrency.SUM" />
              <entry key="positionType" value="PREVIOUS_STREAM" />
              <entry key="reverseDimensionOrder" value="true" />
          </properties>
    </postProcessor>
    

    You should then get the following pivot table:

    Time dimension  | cumulative measure
    2012            |    75
    2011            |    55
    2010            |    40
    2009            |    10