# How to select a car and other data of that car in an other template

**URL:** <https://community.silverfin.com/t/how-to-select-a-car-and-other-data-of-that-car-in-an-other-template/1804>\
**Category:** Templates\
**Tags:** result-tags\
**Created:** [May 29, 2020, 2:03pm UTC](https://community.silverfin.com/t/how-to-select-a-car-and-other-data-of-that-car-in-an-other-template/1804 "2020-05-29T14:03:24Z")\
**Posts on this page:** 15\
**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 29, 2020, 2:03pm UTC](https://community.silverfin.com/t/how-to-select-a-car-and-other-data-of-that-car-in-an-other-template/1804/1 "2020-05-29T14:03:25Z")

</div>

Hi,

Is it possible to select a car that is inserted in the template Wagenpark in an other template?  
if this is selected, is it also possible to give the correct %VU verworpen, like in template “VU autokosten” or “Voordelen van alle aard”

case:  
I would like to create a template “beroepsverplaatsingen” for “eenmanszaken” that calculates the fiscal % and also calculates a proffesional %.

---

<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:** [June 4, 2020, 8:17am UTC](https://community.silverfin.com/t/how-to-select-a-car-and-other-data-of-that-car-in-an-other-template/1804/2 "2020-06-04T08:17:59Z")

</div>

Hi Alexander,

It is possible to loop over all cars in the fleet template, like this:

```auto
{% for car in period.reconciliations.wagenpark.custom.fleet %}
  Taxyear 2021 starting on 01/01/2020 or later:
  {% capture car_disallowed %}car_disallowed_{{ car.key }}{% endcapture %}
  The disallowed % is: {{ period.reconciliations.wagenpark.results.[car_disallowed] }}
{% endfor %}

```

In all other cases, before TY2021, it works a bit different because for those tax years there are fixed ranges of disallowed percentages: 10, 20, 25, 30, 40 and 50%. All cars with a specific % are put into one result tag that you can use as a collection to loop over them, e.g. for 50%:

```auto
{% assign cars_at_50 = period.reconciliations.wagenpark.results.cars_at_50 | split:"," %}

{% for car in cars_at_50 %}
  {{ car }} {% comment %}car is here combination of brandtype and license plate {% endcomment %}
{% endfor %}

```

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:** [December 3, 2020, 9:49am UTC](https://community.silverfin.com/t/how-to-select-a-car-and-other-data-of-that-car-in-an-other-template/1804/3 "2020-12-03T09:49:50Z")

</div>

> [@Michiel](#):
>
> ```auto
> {% for car in period.reconciliations.wagenpark.custom.fleet %}
> Taxyear 2021 starting on 01/01/2020 or later:
> {% capture car_disallowed %}car_disallowed_{{ car.key }}{% endcapture %}
> The disallowed % is: {{ period.reconciliations.wagenpark.results.[car_disallowed] }}
> {% endfor %}
> 
> ```

Michiel,

Is it also possible to loop over resulttag “Car\_total\_fleet”?  
I tried this similar like code mentioned above but it didn’t work.

Is it also possible to loop over the name of the car? (“wagen” or “merk en type”)

Goal is to create a table like this:  
Wagen | totale kost wagen | % privé beperking | kost wagen na privé beperking | %fiscale beperking | kost wagen na Fiscale beperking

---

<div class="post-metadata">

**Author:** ![Gary\_Weimberg](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/gary_weimberg/32/1581_2.png) [@Gary\_Weimberg](https://community.silverfin.com/u/Gary_Weimberg)\
**Post date:** [December 4, 2020, 9:20am UTC](https://community.silverfin.com/t/how-to-select-a-car-and-other-data-of-that-car-in-an-other-template/1804/4 "2020-12-04T09:20:07Z")

</div>

Hi Alexander,

Looping over the car type is possible.

> {% for car in period.reconciliations.wagenpark.custom.fleet %}  
> {{ car.brand\_type }}  
> {% endfor %}

To loop over results you first need to be sure how they are called. You can find it in the code or using [debug](https://community.silverfin.com/t/case-use-debug-mode/1591/10) mode. To access the result and its workings I refer you to our [documentation](https://developer.silverfin.com/docs/result).

Regards,

Gary

---

<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:** [April 22, 2021, 5:20am UTC](https://community.silverfin.com/t/how-to-select-a-car-and-other-data-of-that-car-in-an-other-template/1804/5 "2021-04-22T05:20:40Z")

</div>

Hey, Code mentioned above works just fine.

But I also want to include the “Datum aankoop”, VU% and Total.

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

In fact, I want to create a table looking like this:

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

Yellow is data from wagenpark.  
Collum “Wagen” a select options, so only the ‘personenwagens’ can be selected.  
further more, if a car is bought before 01/01/2018 then an if statement should be made  
if “datum aankoop” is before 01/01/2018 then %aftrekbaar = 75%

---

<div class="post-metadata">

**Author:** ![Robbe\_Dewilde](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/robbe_dewilde/32/1634_2.png) [@Robbe\_Dewilde](https://community.silverfin.com/u/Robbe_Dewilde)\
**Post date:** [April 22, 2021, 8:16am UTC](https://community.silverfin.com/t/how-to-select-a-car-and-other-data-of-that-car-in-an-other-template/1804/6 "2021-04-22T08:16:14Z")

</div>

Hi @AlexanderDB

That is a useful case you are building! 🙂

This should help you get started to build the template you need:

```
{% stripnewlines %}
| Car
| Driver
| Purchase date
| D.E.%
| Total
{% newline %}
|--------
|--------
|:------:
|-------:
|-------:
  {% for car in period.reconciliations.wagenpark.custom.fleet %}
    {% capture car_disallowed %}car_disallowed_{{ car.key }}{% endcapture %}
    {% assign disallowed_percentage = period.reconciliations.wagenpark.results.[car_disallowed] %}

    {% capture car_total %}car_total_{{ car.key }}{% endcapture %}
    {% assign car_total_cost = period.reconciliations.wagenpark.results.[car_total] %}

      {% if disallowed_percentage != blank %}
        {% newline %}
        | {{ car.brand_type }}
        | {{ car.beneficiary }}
        | {{ car.purchasedate | date:"%d/%m/%Y" }}
        | {{ disallowed_percentage | percentage }}
        | {{ car_total_cost | currency }}
      {% endif %}

  {% endfor %}
{% endstripnewlines %}
```

---

<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:** [April 22, 2021, 2:20pm UTC](https://community.silverfin.com/t/how-to-select-a-car-and-other-data-of-that-car-in-an-other-template/1804/7 "2021-04-22T14:20:05Z")

</div>

Robbe,

Thanks for the help.

This is the code I have for now:

```auto
{% stripnewlines %}
| {% t "Car" %}
| {% ic %}{% t "Driver" %} {::infotext as="hover"}Deze kolom is verborgen in "voorbeelweergave"{:/infotext}{% endic %}
| {% ic %}{% t "Purchase date" %} {::infotext as="hover"}Deze kolom is verborgen in "voorbeelweergave"{:/infotext}{% endic %}
| {% t "D.E.%" %}
| {% t "BRUTOBEDRAG" %}
| {% t "BEROEPSBEPERKING (AFTREKBAAR)" %}
| {% t "BEDRAG NA BEROEPSBEPERKING" %}
| {% t "FISCALE BEPERKING (AFTREKBAAR)" %}
| {% t "NETTOBEDRAG" %}

{% newline %}
|--------
|--------
|:------:
|-------:
|-------:
|-------:
|-------:
|-------:
|-------:
{% ic %}#{% endic %}
{% nic %}+{% endnic %}

  {% for car in period.reconciliations.wagenpark.custom.fleet %}
    {% capture car_disallowed %}car_disallowed_{{ car.key }}{% endcapture %}
    {% assign disallowed_percentage = period.reconciliations.wagenpark.results.[car_disallowed] %}

    {% capture car_total %}car_total_{{ car.key }}{% endcapture %}
    {% assign car_total_cost = period.reconciliations.wagenpark.results.[car_total] %}

      {% if disallowed_percentage != blank %}
        {% newline %}
        | {{ car.brand_type }} {{ car.license_plate }}
        | {% ic %}{{ car.beneficiary }}{% endic %}
        | {% ic %}{{ car.purchasedate | date:"%d/%m/%Y" }}{% endic %}
        
        {% assign date_1 = "2018-01-01" %}
        {% assign aankoopdatum = car.purchasedate |date:"%Y-%m-%d" %}
        
        | {% if aankoopdatum > date_1 or car.emission > 199 %}{% assign VU = disallowed_percentage %}{% else %}{% assign VU = 0.25 %}{% endif %} 
          {{ VU |percentage }}
        | {% =$10+ car_total_cost | currency %}
        
{% comment %}beroepspercentage (aftrekbaar) default 100% laten weergeven en automatisch "bedrag na beroepsbeperking" laten berekenen {% endcomment %}

        |*{% input custom.percentageberoepPW.percentage as:percentage %}*
        {% assign defpercPW = custom.percentageberoepPW.percentage %}
        
        |{% assign beroepsbep = defpercPW*car_total_cost %}
        {% =$11+ beroepsbep | currency %}
        |{% assign aftrekbaarfiscaal = 1-VU %}
        {{ aftrekbaarfiscaal | percentage }}
        | {% assign fiscbeperking = beroepsbep*aftrekbaarfiscaal %} 
        {% =$12+ fiscbeperking | currency %}
     
        | 
      {% endif %}
  {% endfor %}
{% newline %}

{% comment %}bereken de totalen van beroeps en fiscale eperkingen{% endcomment %}
| **{% t "Totaal" %}**
|
|
|
|{% assign totpw = $10 as:currency %}
**{{ totpw | currency }}**
|
| {% assign totberoepsbep = $11 as:currency %}
**{{ totberoepsbep | currency }}**
|
|{% assign totfiscbeperking = $12 as:currency %}
**{{ totfiscbeperking | currency }}**
{% endstripnewlines %}

```

Still, I’m struggling with this part:

```auto
{% comment %}beroepspercentage (aftrekbaar) default 100% laten weergeven en automatisch "bedrag na beroepsbeperking" laten berekenen {% endcomment %}

        |*{% input custom.percentageberoepPW.percentage as:percentage %}*

```

If I give a value, e.g. 70,00% in the input field on the first line, it will be the same in the next lines, which is not what I expect.

I should be able to give different values in the next lines.  
I can’t remember how to solve this.

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

Can you help me with this?

---

<div class="post-metadata">

**Author:** ![Robbe\_Dewilde](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/robbe_dewilde/32/1634_2.png) [@Robbe\_Dewilde](https://community.silverfin.com/u/Robbe_Dewilde)\
**Post date:** [April 22, 2021, 3:06pm UTC](https://community.silverfin.com/t/how-to-select-a-car-and-other-data-of-that-car-in-an-other-template/1804/8 "2021-04-22T15:06:28Z")

</div>

Hi @AlexanderDB

The reason for this, is that now you are creating the same inputfield in each iteration of the for loop.

You can create an inputfield based on the `car.key` that is already used to fetch the results from the fleet template.

For example:

```
|{% capture percentageberoepPW %}percentageberoepPW_{{ car.key }}{% endcapture %}
 *{% input custom.[percentageberoepPW].percentage as:percentage %}*
{% assign defpercPW = custom.[percentageberoepPW].percentage %}

```

This way every car has it’s own inputfield to provide the percentage of professional use 🙂

---

<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:** [April 22, 2021, 3:35pm UTC](https://community.silverfin.com/t/how-to-select-a-car-and-other-data-of-that-car-in-an-other-template/1804/9 "2021-04-22T15:35:01Z")

</div>

Robbe,

That’s it!  
I’ve should have know’n this one.

This works,  
Thanks!

---

<div class="post-metadata">

**Author:** ![THANAS](https://avatars.discourse-cdn.com/v4/letter/t/ebca7d/32.png) [@THANAS](https://community.silverfin.com/u/THANAS)\
**Post date:** [May 5, 2021, 2:26pm UTC](https://community.silverfin.com/t/how-to-select-a-car-and-other-data-of-that-car-in-an-other-template/1804/10 "2021-05-05T14:26:47Z")

</div>

Hey @Robbe_Dewilde ,

I am interested in this model, however here is what I get when I copy the code

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

Thank’s for your help,

Kind regards

---

<div class="post-metadata">

**Author:** ![Robbe\_Dewilde](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/robbe_dewilde/32/1634_2.png) [@Robbe\_Dewilde](https://community.silverfin.com/u/Robbe_Dewilde)\
**Post date:** [May 6, 2021, 5:33pm UTC](https://community.silverfin.com/t/how-to-select-a-car-and-other-data-of-that-car-in-an-other-template/1804/11 "2021-05-06T17:33:00Z")

</div>

Hi @THANAS

This example is taking information that was completed in the `fleet` reconciliation template.  
So this will only show the cars that are completed there.

Best regards  
Robbe

---

<div class="post-metadata">

**Author:** ![THANAS](https://avatars.discourse-cdn.com/v4/letter/t/ebca7d/32.png) [@THANAS](https://community.silverfin.com/u/THANAS)\
**Post date:** [May 11, 2021, 6:17pm UTC](https://community.silverfin.com/t/how-to-select-a-car-and-other-data-of-that-car-in-an-other-template/1804/12 "2021-05-11T18:17:36Z")

</div>

hi @Robbe_Dewilde,

In reconciliation “fleet”, the informations are completed but the informations don’t appear.

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

thank’s a lot,

---

<div class="post-metadata">

**Author:** ![Wouter\_Bruynsteen](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/wouter_bruynsteen/32/1196_2.png) [@Wouter\_Bruynsteen](https://community.silverfin.com/u/Wouter_Bruynsteen)\
**Post date:** [May 17, 2021, 8:45am UTC](https://community.silverfin.com/t/how-to-select-a-car-and-other-data-of-that-car-in-an-other-template/1804/13 "2021-05-17T08:45:35Z")

</div>

Hi @THANAS

The code snippet combined with the car information below is displaying the information in the template for me, could you check if this is working for you as well?

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

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

```
{% assign fleet_template = period.reconciliations.wagenpark %}

{% if fleet_template != blank %}

{% stripnewlines %}
| {% t "Car" %}
| {% ic %}{% t "Driver" %} {::infotext as="hover"}Deze kolom is verborgen in "voorbeelweergave"{:/infotext}{% endic %}
| {% ic %}{% t "Purchase date" %} {::infotext as="hover"}Deze kolom is verborgen in "voorbeelweergave"{:/infotext}{% endic %}
| {% t "D.E.%" %}
| {% t "BRUTOBEDRAG" %}
| {% t "BEROEPSBEPERKING (AFTREKBAAR)" %}
| {% t "BEDRAG NA BEROEPSBEPERKING" %}
| {% t "FISCALE BEPERKING (AFTREKBAAR)" %}
| {% t "NETTOBEDRAG" %}

{% newline %}
|--------
|--------
|:------:
|-------:
|-------:
|-------:
|-------:
|-------:
|-------:
{% ic %}#{% endic %}
{% nic %}+{% endnic %}

  {% for car in period.reconciliations.wagenpark.custom.fleet %}
    {% capture car_disallowed %}car_disallowed_{{ car.key }}{% endcapture %}
    {% assign disallowed_percentage = period.reconciliations.wagenpark.results.[car_disallowed] %}

    {% capture car_total %}car_total_{{ car.key }}{% endcapture %}
    {% assign car_total_cost = period.reconciliations.wagenpark.results.[car_total] %}

      
        {% newline %}
        | {{ car.brand_type }} {{ car.license_plate }}
        | {% ic %}{{ car.beneficiary }}{% endic %}
        | {% ic %}{{ car.purchasedate | date:"%d/%m/%Y" }}{% endic %}
        
        {% assign date_1 = "2018-01-01" %}
        {% assign aankoopdatum = car.purchasedate |date:"%Y-%m-%d" %}
        
        | {% if aankoopdatum > date_1 or car.emission > 199 %}{% assign VU = disallowed_percentage %}{% else %}{% assign VU = 0.25 %}{% endif %} 
          {{ VU |percentage }}
        | {% =$10+ car_total_cost | currency %}
        
{% comment %}beroepspercentage (aftrekbaar) default 100% laten weergeven en automatisch "bedrag na beroepsbeperking" laten berekenen {% endcomment %}

        |*{% input custom.percentageberoepPW.percentage as:percentage %}*
        {% assign defpercPW = custom.percentageberoepPW.percentage %}
        
        |{% assign beroepsbep = defpercPW*car_total_cost %}
        {% =$11+ beroepsbep | currency %}
        |{% assign aftrekbaarfiscaal = 1-VU %}
        {{ aftrekbaarfiscaal | percentage }}
        | {% assign fiscbeperking = beroepsbep*aftrekbaarfiscaal %} 
        {% =$12+ fiscbeperking | currency %}
     
        | 
  {% endfor %}
{% newline %}

{% comment %}bereken de totalen van beroeps en fiscale eperkingen{% endcomment %}
| **{% t "Totaal" %}**
|
|
|
|{% assign totpw = $10 %}
**{{ totpw | currency }}**
|
| {% assign totberoepsbep = $11 %}
**{{ totberoepsbep | currency }}**
|
|{% assign totfiscbeperking = $12 %}
**{{ totfiscbeperking | currency }}**
{% endstripnewlines %}

{% endif %}
```

---

<div class="post-metadata">

**Author:** ![THANAS](https://avatars.discourse-cdn.com/v4/letter/t/ebca7d/32.png) [@THANAS](https://community.silverfin.com/u/THANAS)\
**Post date:** [May 31, 2021, 6:50pm UTC](https://community.silverfin.com/t/how-to-select-a-car-and-other-data-of-that-car-in-an-other-template/1804/14 "2021-05-31T18:50:09Z")

</div>

hey @Wouter_Bruynsteen ,

It works.

Is it possible that instead of the percentage in the column “BEROEPSBEPERKING” we can put a number and add a column just after which divides the amount of the column “Brutobedrag” by the number of the column “BEROPSBEPERKING”?

Is it possible that the amount in the “Brutobedrag” column can be changed? In Fleet template, we added an account that we do not want to include in our table here

Thank you so much for your help,

---

<div class="post-metadata">

**Author:** ![Wouter\_Bruynsteen](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/wouter_bruynsteen/32/1196_2.png) [@Wouter\_Bruynsteen](https://community.silverfin.com/u/Wouter_Bruynsteen)\
**Post date:** [June 2, 2021, 10:00am UTC](https://community.silverfin.com/t/how-to-select-a-car-and-other-data-of-that-car-in-an-other-template/1804/15 "2021-06-02T10:00:28Z")

</div>

Hi @THANAS

Yes, those things should be possible:

1. You can change the input type of `{% input custom.percentageberoepPW.percentage as:percentage %}` from `percentage` to `integer` or `currency` to add a number instead of a percentage.
2. You can add this new column by adjusting the numbers of pipes in the headers, table definition & inside `{% for car in period.reconciliations.wagenpark.custom.fleet %}`, where you can then print the calculated amount of Brutobedrag/Beroepsbeperking
3. You can change the amount of the “Brutobedrag” by deducting the amount(s) of the accounts you don’t want to include from the original “Brutobedrag”.

If you need help on some specific parts in the code while making these adjustments, don’t hesitate to ask!

Kind regards  
Wouter
