# CASE: create different variables depending on fiscal year / income yearvariab

**URL:** <https://community.silverfin.com/t/case-create-different-variables-depending-on-fiscal-year-income-yearvariab/1151>\
**Category:** Cases\
**Tags:** variables, case, use\_case\
**Created:** [August 24, 2018, 12:18pm UTC](https://community.silverfin.com/t/case-create-different-variables-depending-on-fiscal-year-income-yearvariab/1151 "2018-08-24T12:18:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sven](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/sven/32/1495_2.png) [@sven](https://community.silverfin.com/u/sven)\
**Post date:** [August 24, 2018, 12:18pm UTC](https://community.silverfin.com/t/case-create-different-variables-depending-on-fiscal-year-income-yearvariab/1151/1 "2018-08-24T12:18:15Z")

</div>

If you want some calculation in your template with variables that have a different value for each fiscal year (or something else like the income year), you can create such variables and make use of the case-statement:

```auto
{% comment %}create variable that displays the fiscal year{% endcomment %}
{% assign fy = period.fiscal_year %}

{% comment %}by a case-statement we'll create certain variables depending on the fiscal year{% endcomment %}
{% case fy %}
{% when 2017 %}
  {% assign tax_perc = 0.25 %}
  {% assign tax = "25%" %}
{% when 2018 %}
  {% assign tax_perc = 0.27 %}
  {% assign tax = "27%" %}
{% else %}
  {% comment %}the else-statement is used to make sure the template can be used even new percentages haven't been released yet{% endcomment %}
  {% assign tax_perc = 0.27 %}
  {% assign tax = "27%" %}
{% endcase %}

{% ic %}
{::infotext}
{% t "The percentages, if not published yet, will take the last know published ones" %}
{:/infotext}
{% endic %}

{% assign profits = -(#60 __68+#70__ 78) %}

<br>

{% comment %}show calculation on when there's actually profits{% endcomment %}
{% if profits > 0 %}
{% t "Calculation tax" %} = {{ profits | currency }} x {{ tax }} = {{ profits*tax_perc | currency }}
{% else %}
{::infotext as="hover"}
{% t "No profits have been made during the year" %}
{:/infotext}
{% endif %}

```

So this assigns the fiscal year into the variable `fy` : `{% assign fy = period.fiscal_year %}`

Then, with the case-statement, you’ll create variables but assigns it to the correct value depending on the case (fiscal year) it is:

```auto
{% case fy %}
{% when 2017 %}
  {% assign tax_perc = 0.25 %}
  {% assign tax = "25%" %}
{% when 2018 %}
  {% assign tax_perc = 0.27 %}
  {% assign tax = "27%" %}
{% else %}
  {% comment %}the else-statement is used to make sure the template can be used even new percentages haven't been released yet{% endcomment %}
  {% assign tax_perc = 0.27 %}
  {% assign tax = "27%" %}
{% endcase %} 

```

You could also create a variable depending on the income year perhaps:

```auto
{% assign income_year = period.year_end_date | date:"%Y" %} 

```

The variable `income_year` is a string-value, so you’ll need to adapt that in your case-statement and call upon that string-value with double quotes:

```auto
{% case income_year %}
{% when "2015" %}
  {% assign tax_perc = 0.25 %}
  {% assign tax = "25%" %}
{% when "2016" %}
  {% assign tax_perc = 0.27 %}
  {% assign tax = "27%" %}
{% else %}
  {% comment %}the else-statement is used to make sure the template can be used even new percentages haven't been released yet{% endcomment %}
  {% assign tax_perc = 0.45 %}
  {% assign tax = "45%" %}
{% endcase %}

```

Output:  
 ![12](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/1X/3bc8f857e53bac74f84de8105da1ca54e022bf86.png)

or

![49](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/1X/bb8d5dcb7f17d49c92e89107d43a5c84433f7077.png)
