2.02-10 Using PREVIOUS() vs CUMULATE()

For long timescales, using PREVIOUS is faster than CUMULATE due to the number of "reads" required for the calculation.  So, the expression should be: 'Calc line item' = 'data line item' + PREVIOUS('Calc line item') rather than CUMULATE('data line item')

 

Exception:
2.02-10a Short Timescales: Where the number of periods is small, Cumulate is faster

 

Best Practice article:
Performance Issues with Cumulate Over Lists

Tagged:

Comments

  • Rule 2.02-10 Using PREVIOUS vs CUMULATE.  For long timescales, using PREVIOUS is faster than CUMULATE due to the number of "reads" required for the calculation.  So, the expression should be: 'Calc line item' = 'data line item' + PREVIOUS('Calc line item') rather than CUMULATE('data line item'). It goes against PERFORMANCE elements of PLANS if you wish to go against this rule

    Here is how it was done in Pre Planual Era: In order to aggregate the data across the timescale we used to use CUMULATE function to do so. Here the timescale is weekly, multiple years

    Misbah_1-1591357051598.png

    What is wrong with this method?  CUMULATE impacts the performance due to the number of “reads” required.

    Exception 2.02-10a Short Timescales: You should use CUMULATE only when the timescale is small. Preferably a Monthly Time Period of 1-2 Years

    Here is how it should be done in Planual Way: You can get the same result by using PREVIOUS instead of CUMULATE.

    Misbah_0-1591356899786.png

     

    One thing to note is that PREVIOUS works only on Time Periods and doesn’t work on Lists whereas CUMULATE works on both.

    When using CUMULATE over a list—this is when using the format CUMULATE (x, y, z)—the performance can be poor with anything that exceeds a few million cells. This is because the function is running on a single CPU thread, which differs from nearly all Anaplan functions. Anaplan gets its efficiency from high levels of concurrent multithreading on the CPU, which is where a calculation is broken down into many smaller tasks that can run in parallel, so it can run much faster.

    Here’s a simple example to illustrate.
    Fig. A shows a 10-second calculation running on a single thread.

    Misbah_0-1591356753353.png

    Fig. A

    Fig. B shows the same calculation split into 10 smaller tasks, so it only takes one second to run. Anaplan servers can use over 100 threads to improve efficiency like this.  

    Misbah_1-1591356765792.png

    Fig. B

    Misbah_0-1602062912611.png

    Fig C

     

     

     

  • Thanks @Misbah for the detailed explaination