# Account collection

**URL:** <https://community.silverfin.com/t/account-collection/118>\
**Category:** Templates\
**Tags:** comments, input, input\_comment\
**Created:** [March 10, 2017, 7:17am UTC](https://community.silverfin.com/t/account-collection/118 "2017-03-10T07:17:50Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wim](https://avatars.discourse-cdn.com/v4/letter/w/da6949/32.png) [@Wim](https://community.silverfin.com/u/Wim)\
**Post date:** [March 10, 2017, 7:17am UTC](https://community.silverfin.com/t/account-collection/118/1 "2017-03-10T07:17:50Z")

</div>

Hi,  
I’m trying to get the value of a selected account using an account collection.

Here’s my code:

```auto
Selecteer hier de rekening geboekte waardevermindering: {% input custom.rekeningen.vw as:account_collection range:'5' accounts_var:vw %}{% for rekeningen in vw %}{{ rekeningen.number }} {{ rekeningen.name }} {{ rekeningen.value | currency }}{% assign vwrek = rekeningen.value %}{% endfor %}

```

In the template the selection box stays empty  
 ![](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/1X/b262b8c624e7291bdfe24bccf78a91409367528e.PNG)

When I add a default account or account range the selection automatically takes the values of the range.  
 ![](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/1X/ec76a0ff032f6880be23f4d900514c67d5ede2be.PNG)

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

Can you help me out?

---

<div class="post-metadata">

**Author:** ![michail](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/michail/32/8_2.png) [@michail](https://community.silverfin.com/u/michail)\
**Post date:** [March 10, 2017, 9:33am UTC](https://community.silverfin.com/t/account-collection/118/2 "2017-03-10T09:33:21Z")

</div>

Hello @Wim,

Try removing your two ’ before and after the number in your range: selection. If you do that, your selection box will not be empty anymore but it will give you the option to choose from all the accounts starting with 5. Your code should be like:

```auto
Selecteer hier de rekening geboekte waardevermindering: {% input custom.rekeningen.vw as:account_collection range:5 accounts_var:vw %}{% for rekeningen in vw %}{{ rekeningen.number }} {{ rekeningen.name }} {{ rekeningen.value | currency }}{% assign vwrek = rekeningen.value %}{% endfor %}

```

I think this will solve your problem.

Regards,  
Michail

---

<div class="post-metadata">

**Author:** ![Wim](https://avatars.discourse-cdn.com/v4/letter/w/da6949/32.png) [@Wim](https://community.silverfin.com/u/Wim)\
**Post date:** [March 10, 2017, 9:58am UTC](https://community.silverfin.com/t/account-collection/118/3 "2017-03-10T09:58:28Z")

</div>

> [@michail](#):
>
> vwrek = rekeningen.value %}{% endfor %}

Oh damn I didn’t see that one. You only need to ‘quote’ the range when you have multiple account ranges like ‘50,51’.

---

<div class="post-metadata">

**Author:** ![michail](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/michail/32/8_2.png) [@michail](https://community.silverfin.com/u/michail)\
**Post date:** [March 10, 2017, 10:00am UTC](https://community.silverfin.com/t/account-collection/118/4 "2017-03-10T10:00:35Z")

</div>

Even then you just have to go with range:6,7 no quotes needed. 🙂 Did this solve your problem by the way?

---

<div class="post-metadata">

**Author:** ![Wim](https://avatars.discourse-cdn.com/v4/letter/w/da6949/32.png) [@Wim](https://community.silverfin.com/u/Wim)\
**Post date:** [March 10, 2017, 10:04am UTC](https://community.silverfin.com/t/account-collection/118/5 "2017-03-10T10:04:47Z")

</div>

Yes indeed this solved my problem.

Now I have an other problem. My explaned formule doesn’t work anymore.

 ![](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/1X/941facdeaef5a5ba5d19f7b321ec5dd14830260b.PNG)

```auto
| **Totaal** ||{% unexplained $3-current_account.value | as:indicator %} **{{ $3 |currency}}** | **{{ $6 |currency}}** | **{{ $7 |currency}}** | **{{ $5 |currency}}** | **{{ $4|currency }}** | **{% unexplained $2-vwrek | as:indicator %}{{ $2 |currency }}** |

```

Can you adjust the template explained formule in the background of Silverfin? Template “Belegging/aandelen” like in topic Explained/Unexplained?

---

<div class="post-metadata">

**Author:** ![michail](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/michail/32/8_2.png) [@michail](https://community.silverfin.com/u/michail)\
**Post date:** [March 10, 2017, 10:16am UTC](https://community.silverfin.com/t/account-collection/118/6 "2017-03-10T10:16:51Z")

</div>

I will have a look at that one too. In the meantime, can you check this post about how to post your code in the community in order to be easier to read?

> [@How to paste your code in a community post](https://community.silverfin.com/t/how-to-paste-your-code-in-a-community-post/64):
>
> When you have to paste a part of your code, the best way to do it is by using three simple quotes —\> ` \<— at the beginning and three at the end of your code. For example instead of writing {% ifi some_var != blank %} this is shown when in input mode or some_var is filled in {% endifi %} you can add the 3 backticks: ` before and after the code, and the code looks like this: {% ifi some\_var != blank %} this is shown when in input mode or some\_var is filled in {% endifi %} This way, it w…

---

<div class="post-metadata">

**Author:** ![michail](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/michail/32/8_2.png) [@michail](https://community.silverfin.com/u/michail)\
**Post date:** [March 10, 2017, 10:48am UTC](https://community.silverfin.com/t/account-collection/118/7 "2017-03-10T10:48:17Z")

</div>

@Tim is the one who has to do his background magic.

---

<div class="post-metadata">

**Author:** ![Tim](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/tim/32/1304_2.png) [@Tim](https://community.silverfin.com/u/Tim)\
**Post date:** [March 10, 2017, 5:13pm UTC](https://community.silverfin.com/t/account-collection/118/8 "2017-03-10T17:13:55Z")

</div>

@Wim I had a look at your template. The problem is that to calculate the green dots on a global level, Silverfin computes the templates based on the ‘non input’ version. That means that a line surrounded with `{% ic %}{% endic %}` will not be taken into account.

So this piece will not be executed when the results are calculated, meaning the accounts will not be used, and you’ll have red dots:

```auto
{%ic%}
Selecteer hier de rekening geboekte waardevermindering: {% input custom.rekeningen.vw as:account_collection range:5 accounts_var:vw %} {% for rekeningen in vw %}{{ rekeningen.number }} {{ rekeningen.name }} : {{ rekeningen.value | currency }}{% assign vwrek = rekeningen.value %}{% endfor %}
{%endic%}

```

The solution here is to either take the input out of the `ic` tags or assign the accounts var out of the `ic` tag, for example by doing

```auto
{% assign vw = period.accounts | range:custom.rekeningen.vw %}

```

---

<div class="post-metadata">

**Author:** ![Wim](https://avatars.discourse-cdn.com/v4/letter/w/da6949/32.png) [@Wim](https://community.silverfin.com/u/Wim)\
**Post date:** [March 11, 2017, 9:07am UTC](https://community.silverfin.com/t/account-collection/118/9 "2017-03-11T09:07:32Z")

</div>

Hi Tim,

The problem isn’t the unexplained one of “Waardervermindering per”.

The account explaination needs to look at the one of “Aanschafwaarde” in my case “$3-current\_account.value”

```auto
| **Totaal** ||{% unexplained $3-current_account.value | as:indicator %} **{{ $3 |currency}}** | **{{ $6 |currency}}** | **{{ $7 |currency}}** | **{{ $5 |currency}}** | **{{ $4|currency }}** | **{% unexplained $2-vwrek | as:indicator %}{{ $2 |currency }}** |

```

When I comment out the last unexplained “$2-vwrek” the template gets a green dot.

---

<div class="post-metadata">

**Author:** ![Tim](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/tim/32/1304_2.png) [@Tim](https://community.silverfin.com/u/Tim)\
**Post date:** [March 13, 2017, 8:23pm UTC](https://community.silverfin.com/t/account-collection/118/10 "2017-03-13T20:23:50Z")

</div>

Hi Wim,

The fact that you have two unexplained tags means that Silverfin will look at both items. As the second unexplained is different from 0, it doesn’t matter what the ‘Aanschafwaarde’ one is, it will always turn out to be red.

Could you try and move it out of the comments and see if that resolves it?

---

<div class="post-metadata">

**Author:** ![Wim](https://avatars.discourse-cdn.com/v4/letter/w/da6949/32.png) [@Wim](https://community.silverfin.com/u/Wim)\
**Post date:** [March 14, 2017, 7:50pm UTC](https://community.silverfin.com/t/account-collection/118/11 "2017-03-14T19:50:01Z")

</div>

Hi Tim,

Didn’t know the unexplained tags looks at all tags all the time.

Taking it outside of the ic tags solved my problem.

Thx

---

<div class="post-metadata">

**Author:** ![Tim](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/tim/32/1304_2.png) [@Tim](https://community.silverfin.com/u/Tim)\
**Post date:** [March 14, 2017, 9:47pm UTC](https://community.silverfin.com/t/account-collection/118/12 "2017-03-14T21:47:39Z")

</div>

Closed on March 14, 2017, 9:47pm UTC


