How to capture a result of a forecast for use in another formula

Hi @Sam

I want to use the Net Revenue result of the year 2020 in a different formula. ( see example on the print screen).
I have tried several things including assign and capture but it does not work.
Do you know a way to do this?


{% assign net_revenue = period.accounts | range: “70” %}

{% assign growth_perc = 1.02 %}

{% assign start_date = period.year_start_date | date:"%Y" %}
{% assign end_date = period.year_end_date | date:"%Y" %}

| Description |{% if start_date == end_date %}{{ start_date }}{% else %}{{start_date}} - {{end_date}}{% endif %}{% for i in (1…5) %} | {{ INT(start_date+i) }}{% endfor %}
|------------|----------|----------{% for i in (0…4) %}|----------{% endfor %}+
|Net Revenue | {{ -1net_revenue | currency }} {% for i in (0…4) %}| {{ -1growth_percnet_revenue | currency }} {% assign net_revenue = growth_percnet_revenue %} {% endfor %}


Hi @NickS,

To extract an amount from your for-loop, you should first make sure you take the amount from the correct loop. You can do this by adding

{% case forloop.index0 %} … {% endcase %}

in you code.

By using different cases, you can than extract the amount depending on which loop the amount is calculated, e.g.

{% when 0 %}{% assign value_2018 = -1 growth_perc net_revenue %}{% when 1 %}{% assign value_2019 = -1 growth_perc net_revenue %}{% when 2 %}{% $1+ (-1 growth_perc net_revenue) %}

You can extract the amount by assigning the amount to a variable, or by using a register (see above).

Please find the complete code below.

{% assign net_revenue = period.accounts | range: “70” %}

{% assign growth_perc = 1.02 %}

{% assign start_date = period.year_start_date | date:“%Y” %}
{% assign end_date = period.year_end_date | date:“%Y” %}

| Description |{% if start_date == end_date %}{{ start_date }}{% else %}{{start_date}} - {{end_date}}{% endif %}{% for i in (1…5) %} | {{ INT(start_date+i) }}{% endfor %}
|------------|----------|----------{% for i in (0…4) %}|----------{% endfor %}+
|Net Revenue | {{ -1 net_revenue | currency }} {% for i in (0…4) %}| {% case forloop.index0 %}{% when 0 %}{% assign value_2018 = -1 growth_perc net_revenue %}{% when 1 %}{% assign value_2019 = -1 growth_perc net_revenue %}{% when 2 %}{% $1+ (-1 growth_perc net_revenue) %}{% endcase %}{{ -1 growth_perc net_revenue | currency }} {% assign net_revenue = growth_perc net_revenue %} {% endfor %}

{{ value_2018 | currency }}
{{ value_2019 | currency }}
{{ $1 | currency }}

Note that the multiplier-symbol should be added in above code (‘*’).

Finally, may we kindly ask you to always share your code using the ‘blockquote’ (i.e. ‘>’ sign in front of your code) in order to avoid copy/paste misunderstandings.

Thank you!

Kind regards,
Robin

Hi @robindeclercq

this works perfectly
Thank you.

p.s. sorry for forgetting the ‘>’ sign