Dynamic formulation for full year / rolling 13 months
Hello everyone,
We currently use the following formulations to ultimately display the rolling last 13 months ("Rollierend") or the entire year ("Gesamtjahr") via a button in the dashboard.
- Dashboard -
- Formula rolling 13 months -
- Formula entire year -
Since the formulation only refers to the current year and will have to be changed at the turn of the year 2026, for example, it is still very static.
It would also be better if the formula were based on the calendar used in the dashboard, so that the rolling 13 months could be displayed based on the current month ("Jahr" 2025, "Monat" April), but also further back in the past.
Does anyone have any ideas and can help me optimise the mdx formula?
Thanks and best regards,
Jona
10 replies
-
There is a much simpler way of doing this - but it requires some formula logic. You need to use a parameter and a list and it should (hopefully) solve all the issues.
- First, build a new Parameter (from the Formulate section).
- Start by choosing your "model" parameter, then choose your cube.
- Select 'data driven' and then pick your months hierarchy ("Jan 2025"), and then select all your months in the list. These will be the starting months that you pick from later.
- For 'default', choose single select drop down, and 'last' value.
- Save it.
- Next, build a new List (also from Formulate section). We'll start with point and click and then change to script mode.
- Select your cube again.
- Choose a "Range List" from the "add" menu.
- In the bottom panel, for the first 'pick a member', select your months attribute. In the elements list, click the 'FX" button and choose the parameter you created above.
- Repeat this for the second 'pick a member'.
- Now change to script mode. You see syntax like this. It says pick a range of elements starting with the parameter (the strange ID) and ending in the parameter.
{([Date].[Month].@[5d9bcfea-4d70-48f0-a6b6-e348d737d3d8] :[Date].[Month].@[5d9bcfea-4d70-48f0-a6b6-e348d737d3d8])}
- Of course, this is not what we want. We want to pick from the date and range it back 13 months. so adjust the formula manually with the lag function as follows:
{([Date].[Month].@[5d9bcfea-4d70-48f0-a6b6-e348d737d3d8].lag(12) :[Date].[Month].@[5d9bcfea-4d70-48f0-a6b6-e348d737d3d8])}
That's it. Go into Discover and use your list. When you do, you'll automatically be presented with the parameter drop down. Pick your end month from the drop down, and the query will show you a list of months going back 13 periods.
- First, build a new Parameter (from the Formulate section).
-
No I mean to show the total year (Jan - Dez) in the lines when selecting a random Month of the year instead of the rolling 13 months.
-
Thank you for helping out. That's exactly what I want to achieve with the additional Formula.
Unfortunately, the post doesn't really help me with this specific issue.
So it would be great if someone could take another look at it so that I can replace the static code for the entire year with a dynamic formula.The static formula currently has to be adjusted and replaced at the beginning of each new year. This involves additional work that we could potentially save ourselves.
Thank you in advance!