Using a total of a Column as part of a calculation in a row

Hi,

I’m trying to make a calculation as follows:
In cell in column “Herkwalificatie”
"value in “in aanmerking te nemen leningen”/ “Totaal in aanmerking te nemen leningen” * “Totaal Max. R/C” * “Rentetarief”

for example:
in the row of “489010.001 R/C Bestuurder/zaakvoerder” in cel Herkwalificatie I want to have the following calculation:
1.458.568,16 / 1.517.126,32 *950.936.32 * 2,00%

in row "489010.002 R/C Bestuurder/zaakvoerder:
58.588,16 / 1.517.126,32 * 950.936,32 * 4,00%

I can’t manage to get the total of a column in a cel of the next column.!
herkwal|689x225

{% for rc in rc_accounts %}
  {% newline %}
  {% comment %}display account and number as linkto{% endcomment %}
  | {{ rc.link }}
  |{% input rc.custom.rente.tarief as:percentage %}
  | {% input rc.custom.boolean.marktrente as:boolean %}
    {% if rc.custom.boolean.marktrente == 'true' %}Ja {% else %} Nee{% endif %}
  | {% =$35+ -rc.value | currency %} 
  {% assign rentetarief_RC = rc.custom.rente.tarief %}
  | {% if rentetarief_RC != 0 %}{% =$36+ -rc.value | currency %} {% endif %}
 
  | 
  {% assign rekening_courant = -rc.value %}
  | {% comment %}calculation = -rc.value / total in aanmerking te nemen lening * total max R/C * rc.rente.tarief  {% endcomment %}
 
{% endfor %}
{% newline %}
    | **Totaal**
    |
    |
    | **{{ $35 | currency }}**
 
    | **{{ $36 | currency }}**
  {% assign basis_overschreden_RC = =$36 %}
  
    | {% if $36 > Base %}
    **Maximum R/C {{ $36-Base | currency }} overschreden**
    
    {% else %}
    **oke**
    {% endif %}
  {% comment %}total of comumn Herkwalificatie{% endcomment %}
    | **{{ $37 | currency }}**
{% endstripnewlines %}

Hi @AlexanderDB,

It’s true that it will not be possible to get the total of a column and use it in a cel in the table above. This is because liquid-code always executes from top to bottom. The value you’ll get in your table for f.i. $35 will be the accumulated value of $35 until that specific row.

If you want to use the total amount of $35 or $36 you can do the following:

  • Above your table you loop through the array rc_accounts;
  • In this loop, you calculate the total amount of rc.value via a register;
  • Now you can use this register in your table for the calculation of the Herkwalificatie amount.

For example,

{% for rc in rc_accounts %}
{% $4+ rc.value %}
{% endfor %}

In this example, $4 can be used in your formula.

Hope this helps!

Kind regards,
Robin

Hi @robindeclercq

code mentioned above works for the total “BEDRAG LENING”

Would it also work if I put an If statement in this piece of code?
for example:

{% for  in rc_accounts %}
{% if rentetarief_RC != 0 %}{% $38+ -rc.value %}{% endif %}
{% endfor %}


So In fact I want the total of in aanmerking te nemen leningen (1.517.126,32) in stead of (2.942.126,32) in the column “Herkwalificatie”

The total of “In aanmerking te nemen leningen” is as follows:

% assign rentetarief_RC = rc.custom.rente.tarief %}
  | {% if rentetarief_RC != 0 %}{% =$36+ -rc.value | currency %} {% endif %}
....
{% newline %}
....
   | **{{ $36 | currency }}**
....

even more,
Actually I have to make the following calculation:
{{ rc.value / 1.517.126,32 * 950.936,32 * rentetarief_RC }} in each row of the column “HERKWALIFICATIE”