# Account value prior year

**URL:** <https://community.silverfin.com/t/account-value-prior-year/2396>\
**Category:** Reports\
**Tags:** export, for\_loop\
**Created:** [January 30, 2023, 8:19pm UTC](https://community.silverfin.com/t/account-value-prior-year/2396 "2023-01-30T20:19:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![FBOG](https://avatars.discourse-cdn.com/v4/letter/f/b9e5f3/32.png) [@FBOG](https://community.silverfin.com/u/FBOG)\
**Post date:** [January 30, 2023, 8:19pm UTC](https://community.silverfin.com/t/account-value-prior-year/2396/1 "2023-01-30T20:19:52Z")

</div>

Hi, i’m trying to create a custom report to confirm the balance of the current account.  
I have 2 issues:  
1- I don’t succeed in getting the correct amount for each selected account. The code only makes a sum of all selected accounts. I don’t have the problem for the current year data.  
2- When exporting, the PDF-file remains empty.

Thanks!

 ![screenshot](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/2X/8/8a040c60360a3c06ee5ea89a0073f894e422c3c9.png)

For now i have the following code:

````auto
{% include "parts/translation" %}

{% ic %}
Selecteer rekeningen: {% input custom.accounts.total as:account_collection range:"416,48" accounts_var:accounts_rc %}
{% assign prev_date = period.year_end_date|%d/%m/%Y %}
{% assign new_date = prev_date |retract_years:1 %}
{% endic %}

<table class="usr-bordered usr-width-100">
  <thead class="usr-repeated-header">
    <tr>
      <th class="usr-align-center"> **{% t "t_rc" %}** </th>
      <th class="usr-align-center"> **{% t "t_amount" %} {{ period.year_end_date|date:"%d/%m/%Y" }}** </th>
      <th class="usr-align-center"> **{% t "t_amount" %} {{ new_date| date: "%d/%m/%Y" }}** </th>
    </tr>
  </thead>
  <tbody>

     {%for account in accounts_rc%}
    {% assign account_value_py = period.minus_1y.accounts | range:custom.accounts.total %}
    <tr>
      <td>{{ account.name }}</td>
      <td class="usr-align-right">{{ account.value|currency }}</td>
      <td class="usr-align-right">{{ account_value_py|currency }}</td>    
    </tr>
    {% endfor %}
  </tbody>
</table>```
````

---

<div class="post-metadata">

**Author:** ![Romy\_Vermeeren](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/romy_vermeeren/32/2295_2.png) [@Romy\_Vermeeren](https://community.silverfin.com/u/Romy_Vermeeren)\
**Post date:** [January 31, 2023, 8:03am UTC](https://community.silverfin.com/t/account-value-prior-year/2396/2 "2023-01-31T08:03:19Z")

</div>

Hi @FBOG

I’m glad to see you’re using HTML tables, it’s looking pretty good already!

First off, I do notice you’ve assigned `accounts_rc` within ic-tags.  
That will pose an issue in export, so I would recommend defining that variable outside of the ic-tags:

`{% assign accounts_rc = period.accounts.include_zeros | range:custom.accounts.total %}`

Next off, the reason you’re seeing the total value for the previous year is this line:

`{% assign account_value_py = period.minus_1y.accounts | range:custom.accounts.total %}`

→ the range applied is every account selected.  
What you actually want is the account number for every iteration, which looks like this since you’re already looping over the accounts:

`{% assign account_value_py = period.minus_1y.accounts.include_zeros | range:account.number %}`

For your second issue regarding the PDF export, it might depend on the style you’re using.  
Can you try with a different style? If you create a new blank style, that should export any template as the detail text in the style settings is empty.  
Please also make sure the **Virtual Account Number** has been filled out, a template cannot be exported if this is empty.

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

Hope this helps,  
Kind regards  
Romy

---

<div class="post-metadata">

**Author:** ![FBOG](https://avatars.discourse-cdn.com/v4/letter/f/b9e5f3/32.png) [@FBOG](https://community.silverfin.com/u/FBOG)\
**Post date:** [February 2, 2023, 6:38pm UTC](https://community.silverfin.com/t/account-value-prior-year/2396/3 "2023-02-02T18:38:55Z")

</div>

Thanks Romy!

Adjustments worked out fine!
