# Automatically copy data to different periods with default string

**URL:** <https://community.silverfin.com/t/automatically-copy-data-to-different-periods-with-default-string/1477>\
**Category:** Templates\
**Created:** [May 13, 2019, 1:36pm UTC](https://community.silverfin.com/t/automatically-copy-data-to-different-periods-with-default-string/1477 "2019-05-13T13:36:16Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlexanderDB](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@AlexanderDB](https://community.silverfin.com/u/AlexanderDB)\
**Post date:** [May 13, 2019, 1:36pm UTC](https://community.silverfin.com/t/automatically-copy-data-to-different-periods-with-default-string/1477/1 "2019-05-13T13:36:16Z")

</div>

hi,

i’m building a template in which I want to calculate “Bedrag na beroepsbeperking” using the following columns:  
**Omschrijving:** `{{beperking.link}}` using `{% for beperking in beperking_accounts %}` to make a loop  
**Brutobedrag :** `{% =$0+ beperking.value | currency %}`  
**Beroepsbeperking (aftrekbaar)**:  
`*{% input period.beperking.custom.beroepsbeperking.percentage as:percentage | default:"1" %}* {% assign beroepsperc = period.beperking.custom.beroepsbeperking.percentage as:currency %} {% assign defperc = beroepsperc | default:"1" %} {% assign beroepsbedrag = beperking.value*defperc as:currency %}`  
**Bedrag na beroepsbeperking** : `{% =$1+ beroepsbedrag | currency %}`

Result is a table like this in for example period 31/12/2018:

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

But when I want to copy these values in collumn “Beroepsbeperking (aftrekbaar)” from one period (31/12/2018) to an other (31/12/2017) then the default value is given in stead of the adjusted vallue.

I cant quite figure out why the default value is given.  
What am I doing wrong?

Also can a Template be copied automatically to all existing periods?

---

<div class="post-metadata">

**Author:** ![Michiel](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/michiel/32/2364_2.png) [@Michiel](https://community.silverfin.com/u/Michiel)\
**Post date:** [May 13, 2019, 1:43pm UTC](https://community.silverfin.com/t/automatically-copy-data-to-different-periods-with-default-string/1477/2 "2019-05-13T13:43:52Z")

</div>

Hi Alexander,

your input variable is linked to your period (starts with _period._ ). Unless it’s a text template, these variables can never be copied/rollforwarded to other periods.

Regards,

Michiel

---

<div class="post-metadata">

**Author:** ![AlexanderDB](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@AlexanderDB](https://community.silverfin.com/u/AlexanderDB)\
**Post date:** [May 13, 2019, 2:02pm UTC](https://community.silverfin.com/t/automatically-copy-data-to-different-periods-with-default-string/1477/3 "2019-05-13T14:02:29Z")

</div>

Michiel,

true,

I’ve made the adjustment:

> | {{ beperking.link }}  
> | {% =$0+ beperking.value | currency %}  
> {% comment %}beroepspercentage (aftrekbaar) default 100% laten weergeven en automatisch “bedrag na beroepsbeperking” laten berekenen {% endcomment %}  
> | _{% input beperking.custom.beroepsbeperking.percentage as:percentage | default:“1” %}_  
> {% assign beroepsperc = beperking.custom.beroepsbeperking.percentage as:currency %}  
> {% assign defperc = beroepsperc | default:“1” %}  
> {% assign beroepsbedrag = beperking.value\*defperc as:currency %}  
> | {% =$1+ beroepsbedrag | currency %}``

But still the defaults are given when template is copied to another period.

---

<div class="post-metadata">

**Author:** ![AlexanderDB](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@AlexanderDB](https://community.silverfin.com/u/AlexanderDB)\
**Post date:** [May 15, 2019, 8:20am UTC](https://community.silverfin.com/t/automatically-copy-data-to-different-periods-with-default-string/1477/4 "2019-05-15T08:20:16Z")

</div>

Hi,

I still have not found why a certain percentage entered in the “BEROEPSBEPERKING (AFTREKBAAR)” column is not copied to another period.

example:  
period 30/06/2015:

I changed the percentage of Erelonen to 50%:

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

I want to copy this to period 30/06/2016:  
the percentage of Erelonen is back 100%, but it should be 50%

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

for the table I used following Code:

> {% for beperking in beperking\_accounts %}  
> {% newline %}  
> | {{ beperking.link }}  
> | {% =$0+ beperking.value | currency %}  
> {% comment %}beroepspercentage (aftrekbaar) default 100% laten weergeven en automatisch “bedrag na beroepsbeperking” laten berekenen {% endcomment %}  
> |_{% input beperking.custom.beroepsbeperking.percentage as:percentage | default:“1” %}_  
> {% assign beroepsperc = beperking.custom.beroepsbeperking.percentage as:currency %}  
> {% assign defperc = beroepsperc | default:“1” %}  
> {% assign beroepsbedrag = beperking.value\*defperc as:currency %}  
> | {% =$1+ beroepsbedrag | currency %}

---

<div class="post-metadata">

**Author:** ![Michiel](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/michiel/32/2364_2.png) [@Michiel](https://community.silverfin.com/u/Michiel)\
**Post date:** [May 15, 2019, 10:00am UTC](https://community.silverfin.com/t/automatically-copy-data-to-different-periods-with-default-string/1477/5 "2019-05-15T10:00:53Z")

</div>

Hi Alexander,

How is your collection beperking\_accounts defined? Can you try to change _beperking.custom.beroepsbeperking.percentage_ to _beperking.percentage_?

Regards,

Michiel

---

<div class="post-metadata">

**Author:** ![AlexanderDB](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@AlexanderDB](https://community.silverfin.com/u/AlexanderDB)\
**Post date:** [May 15, 2019, 10:09am UTC](https://community.silverfin.com/t/automatically-copy-data-to-different-periods-with-default-string/1477/6 "2019-05-15T10:09:55Z")

</div>

Michiel,

beperking\_accounts is defined as follows:

> {% assign beperking\_accounts = period.accounts.include\_zeros | range:custom.range.beperkingen %}

so

> {% input beperking.custom.beroepsbeperking.percentage as:percentage | default:“1” %}

sould be

> {% input beperking.percentage as:percentage | default:“1” %}

?

---

<div class="post-metadata">

**Author:** ![Michiel](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/michiel/32/2364_2.png) [@Michiel](https://community.silverfin.com/u/Michiel)\
**Post date:** [May 15, 2019, 10:53am UTC](https://community.silverfin.com/t/automatically-copy-data-to-different-periods-with-default-string/1477/7 "2019-05-15T10:53:16Z")

</div>

Hi Alexander,

In this case your collection will be linked to your period. Best option is to use the key of your forloop to create the input percentage field. The code could look like this

```auto
{% for beperking in beperking_accounts %}
{% newline %}
| {{ beperking.link }}
| {% =$0+ beperking.value | currency %}
{% comment %}beroepspercentage (aftrekbaar) default 100% laten weergeven en automatisch “bedrag na beroepsbeperking” laten berekenen {% endcomment %}
{% capture key %}{{ beperking.number }}{% endcapture %}
|{% input custom.percentage[key] as:percentage | default:"1" %}
{% assign beroepsperc = custom.percentage[key] as:currency %}
{% assign defperc = beroepsperc | default:"1" %}
{% assign beroepsbedrag = beperking.value*defperc as:currency %}
| {% =$1+ beroepsbedrag | currency %}

```

However, to make your code more efficient I would change this:

```auto
{% assign beroepsperc = custom.percentage[key] as:currency %}
{% assign defperc = beroepsperc | default:"1" %}

```

to this:

```auto
{% assign defperc = custom.percentage[key] | default:"1" %}

```

Kind regards,

Michiel

---

<div class="post-metadata">

**Author:** ![AlexanderDB](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@AlexanderDB](https://community.silverfin.com/u/AlexanderDB)\
**Post date:** [May 15, 2019, 11:22am UTC](https://community.silverfin.com/t/automatically-copy-data-to-different-periods-with-default-string/1477/8 "2019-05-15T11:22:36Z")

</div>

It works!

Thanks!

---

<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:** [May 20, 2019, 10:59am UTC](https://community.silverfin.com/t/automatically-copy-data-to-different-periods-with-default-string/1477/9 "2019-05-20T10:59:07Z")

</div>


