# Intermediate \[Exercise 2: Default & Assign\] (Training slides exercise)

**URL:** <https://community.silverfin.com/t/intermediate-exercise-2-default-assign-training-slides-exercise/1741>\
**Category:** Exercises\
**Tags:** default, assign, exercises, training, intermediate\
**Created:** [April 7, 2020, 1:15pm UTC](https://community.silverfin.com/t/intermediate-exercise-2-default-assign-training-slides-exercise/1741 "2020-04-07T13:15:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![borjaGonzalez](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/borjagonzalez/32/825_2.png) [@borjaGonzalez](https://community.silverfin.com/u/borjaGonzalez)\
**Post date:** [April 7, 2020, 1:15pm UTC](https://community.silverfin.com/t/intermediate-exercise-2-default-assign-training-slides-exercise/1741/1 "2020-04-07T13:15:43Z")

</div>

Create an input field with the data type ‘currency’ and a default value of zero (remember to use the assign attribute in order to store the default value in the database). If the entered value in the input field is positive, create a variable called ‘financial\_result’ and assign the text string ‘profit’ to it, if the value is negative the text string will be ‘loss’ and if the value is zero the text string will be ‘result’.

Finally print the following text in which the second word will be the variable ‘financial\_result’ and the final value will be the input value entered previously:

_**“The profit/loss/result for the current financial year is (input value entered)”**_

You should get something like this at the end (with wording changing when different values are entered):

**![|302px;x85px;](https://lh3.googleusercontent.com/NseLzR9TeE8_DWqF17bWS3PXxp_56llmeG44porLniFJUUm44DuFvWsLTbUsWo09nClpkSD6DiGqjPJFf8sG1ADxPKRSA74yzGBHP77F-bnmWNjDBAMQcBGNg9DyucDf7LT75MGQF1ODOK0znz4IGgUo=s2048)**

---

<div class="post-metadata">

**Author:** ![borjaGonzalez](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/borjagonzalez/32/825_2.png) [@borjaGonzalez](https://community.silverfin.com/u/borjaGonzalez)\
**Post date:** [April 7, 2020, 1:17pm UTC](https://community.silverfin.com/t/intermediate-exercise-2-default-assign-training-slides-exercise/1741/2 "2020-04-07T13:17:02Z")

</div>

Solution:

```auto
{% input custom.profit.cy as:currency default:0 assign:profit %}

{% if profit > 0 %}
  {% assign financial_result = 'profit' %}
{% elsif profit < 0 %}
  {% assign financial_result = 'loss' %}
{% else %}
  {% assign financial_result = 'result' %}
{% endif %}

The {{ financial_result }} for the current financial year is {{ profit }}

```
