Cumulative Rate Changes
Hi all,
I am trying to replicate the example seen in the picture. As you can see, with each different year the rate % changes. I want to be able to track the cumulative change from a given year onwards. So start at 100% and then + each years rate change (creating a cumulative amount) and then use this as the new base to add next years rate change % to. Is there a way of doing this in Pyramid?
Thanks,
Dan
16 replies
-
Hi Dan,
I have some good news and some (slightly) bad news...
The good news is:
The (slightly) bad news, or, depending on how you see it, more good news, is that this requires Pyramid 2020.10.xxx in order to work.
The reason for this is that the cumulative calculation relies on the upgraded version of the PQL CurrentMember function available in Pyramid 2020.10. Great reason to upgrade as soon as possible though when this gets released in a week or so.
I created a simple model using the data you provided in your example spreadsheet.
Then I built a Rate Change from Base calculation in formulate thus:
The multiplication by -1 is to get the sign right for the Rate Change direction and subsequent cumulative process.
Then I built a Cumulative Rate Change thus:
I.e. Starting at the base, for each year add up the Rate Change from Base from 2013 to the current year (Year, CurrentMember block).
In the current version, 2020.05, CurrentMember only returns a value, not the member name, thus cannot be used as part of the RANGE function, as the RANGE function expects a member name for the start and end of the range.
2020.10 enhances CurrentMember() to return the Member name where required. This greatly enhances the calculation capability, especially for this type of dynamic range calculations defined in the Measure dimension.
Keep an eye out for the release announcement, best done by following the Product Announcement forum.
Hope that helps.
Ian
-
BTW - Your cumulative (compound) rate change numbers don't look right. My numbers match exactly the numbers generated by Excel when I prototyped the calculations to make sure I understood them properly.
For example, in your numbers for 2016, it shows a -5.9% change from base. Subtracting that from the previous cumulative value, 76.86% gives 70.96% not 72.34%.
Unless, of course, I've misunderstood your algorithm. However, that doesn't really impact the core approach.
Ian
-
Hi Ian, that's great! Thanks so much for getting back to me. Will give this a go when released - and thanks for the heads up re the calc, probably a cell that wasn't copied down or something but good to see it can be done in the upcoming version!
-
Hi Dan,
Re-examining your grid I now better understand the algorithm you are using to calculate your compound rate change column. Here's the result, which matches your Excel grid:
The revised compound rate change calculation is not a simple cumulative total as I previously thought and is rather more involved, but is still achievable.
Regards,
Ian
-
Err... Yes. The revised calculation takes into account the fact that it is not a simple cumulative total, but that the result the calculation for one row feeds into the calculation for the next row. It's a pseudo recursive calculation.
Unfortunately if you try and code this in PQL it gives a circular reference error. Each term then has to be specified explicitly, which makes the calculation expression huge when you get past 2 or 3 rows. It works, but is very unwieldy.
LMK if you'd like me to share it with you through email.
Cheers,
Ian
-
OK. I'll DM you to set up a call.
Ian
-
Hi, we are attempting a similar use case for Pyramid. We have a data source with data at the daily level for return %, and we want to calculate cumulative aggregate return % based on what rows are available which will be controlled by a date slicer (so we cannot pre calculate the value in the model, it must be done in formulate / discover). While we see an aggregate SUM function, there is no similar aggregate PRODUCT function which is the excel functionality we are trying to mimic (product of all of the values in a single column). How would we implement this functionality within Pyramid?
-
Here is the excel functionality we want to replicate:
We want to take the product of 1+ each daily return % and then subtract 1 from that cumulative product. This will represent the cumulative aggregate return % across the time selected (which is the month of September 2023 in this example).
-
Thank you for the update Ian, that function sounds like exactly what we need. Is there a timeline in mind for the next Pyramid release? Please let me know if this feature does get included in the next release.
-
Hi Malavika,
Yes, it is planned for the next release, which hopefully will be with you in early December.
Ian
-
Awesome - thank you!
-
While there are several alternatives to address the requirement, a new specific PQL function - "Multiply" - has been implemented in our latest release Pyramid 2023.10 to solve this question directly.
Please find full release details here and a list of all implemented forum ideas here. Thank you for your participation and support.