# Result tag in foriloop?

**URL:** <https://community.silverfin.com/t/result-tag-in-foriloop/546>\
**Category:** Templates\
**Tags:** iterations, result, fori\_loop\
**Created:** [December 18, 2017, 5:18pm UTC](https://community.silverfin.com/t/result-tag-in-foriloop/546 "2017-12-18T17:18:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thijs](https://avatars.discourse-cdn.com/v4/letter/t/a4c791/32.png) [@Thijs](https://community.silverfin.com/u/Thijs)\
**Post date:** [December 18, 2017, 5:18pm UTC](https://community.silverfin.com/t/result-tag-in-foriloop/546/1 "2017-12-18T17:18:59Z")

</div>

How can I use a result tag in a foriloop?

Reconciliation template code:

```
{% fori overeenstemming in custom.overeenstemmingen %}

{% input overeenstemming.bedrijfsleider %}

{% assign $1 = 0 %}
{% assign $2 = 0 %}

{% capture bezoldiging_key = %}bezoldiging_{{ overeenstemming.key }}{% endcapture %}

{% fori bezoldiging in custom[bezoldiging_key] %}
{% $1+input bezoldiging.aa %}{% $2+input bezoldiging.bb %}{% endfori %}
Totaal {{ $1+$2 | currency }}

{% result 'totaal' $1+$2 %}

{% endfori %}

```

Reconciliation input mode:

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

My text template code:

`{{ period.reconciliations.test_totaal.results.totaal | currency }}`

Text:

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

---

<div class="post-metadata">

**Author:** ![Thijs](https://avatars.discourse-cdn.com/v4/letter/t/a4c791/32.png) [@Thijs](https://community.silverfin.com/u/Thijs)\
**Post date:** [December 19, 2017, 7:28am UTC](https://community.silverfin.com/t/result-tag-in-foriloop/546/2 "2017-12-19T07:28:51Z")

</div>

I want to use the $1+$2 of every loop displayed in a text template. I tried to use:

```
{% fori overeenstemming in period.custom.overeenstemmingen %}

{% input overeenstemming.bedrijfsleider %}

{% assign $1 = 0 %}
{% assign $2 = 0 %}

{% capture bezoldiging_key = %}bezoldiging_{{ overeenstemming.key }}{% endcapture %}

{% fori bezoldiging in custom[bezoldiging_key] %}
{% $1+input bezoldiging.aa %}{% $2+input bezoldiging.bb %}{% endfori %}
Totaal {{ $1+$2 | currency }}

{% assign overeenstemming.bezoldiging_totaal = $1+$2 %}

{% endfori %}

```

and then:

```
{% for overeenstemming in period.custom.overeenstemmingen %}
{{ overeenstemming.bezoldiging_totaal }}
{% endfor %}

```

But didn’t work.

Is there another option?

---

<div class="post-metadata">

**Author:** ![SamVanEenoo](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/samvaneenoo/32/134_2.png) [@SamVanEenoo](https://community.silverfin.com/u/SamVanEenoo)\
**Post date:** [December 20, 2017, 1:01pm UTC](https://community.silverfin.com/t/result-tag-in-foriloop/546/3 "2017-12-20T13:01:44Z")

</div>

Hi @Thijs

In the beginning of your fori loop you are assigning $1 and $2 to zero. Your result tag is overwritten at the end of every foriloop. So in the last stage of your loop, your $1 = 0 and your $2 = 0. This is why your totaal = 0 as well…

Concerning your second question: overeenstemming.bezoldiging\_totaal is a custom drop variable. Custom drop variables can only be used as an input. You can use assign to safe a variable in a custom drop variable.

My solution looks something like this. Take whatever you want from it. 🙂

{% fori overeenstemming in period.custom.overeenstemmingen %}

{% input overeenstemming.bedrijfsleider %}

{% assign $1 = 0 %}  
{% assign $2 = 0 %}

{% fori bezoldiging in custom[overeenstemming.key] %}  
{% $1+input bezoldiging.aa %}{% $2+input [bezoldiging.bb](http://bezoldiging.bb) %}  
{% endfori %}  
{{ $1+$2 | currency }}

{% endfori %}

```
{% for overeenstemming in period.custom.overeenstemmingen %}
  {% assign totaal = 0 %}
  {% for bezoldiging in custom[overeenstemming.key] %}
    {% assign totaal = totaal+bezoldiging.aa+bezoldiging.bb %}
  {% endfor %}
  Totaal: {{totaal | currency}}
{% endfor %}
```
