If function (and/or)

Beste, ik wil onderstaande if functie uitvoeren maar hij laat niets zien indien ik exporteer en de if functies vervuld zou moeten zijn. Kan je aub helpen?

{% if (period.reconciliations.reserves_and_dividends.results.distributeddividends > 0 and (period.reconciliations.breakdownofprofit.custom.breakdownofprofit.nid1 +
 period.reconciliations.breakdownofprofit.custom.breakdownofprofit.nid2) > 0 )) or (period.reconciliations.reserves_and_dividends.results.distributeddividends > 0 and (period.reconciliations.breakdownofprofit.custom.breakdownofprofit.tlcf1 +
 period.reconciliations.breakdownofprofit.custom.breakdownofprofit.tlcf2) > 0 )) %}

Hello @marnixcoudre,

You cannot use parentheses to simulate an order of operations and control the order of operator evaluation. Also when you want to sum something, you don’t have to use space between them and the plus sign.I tried it for you with no parentheses and it worked fine for me. This is my example:

{% assign $0 = 0 %}
{% assign $1 = 0 %}
{% assign $2 = 0 %}
{% assign $3 = 0 %}
{% assign $4 = 0 %}


{% if $0 > 0 and $1+$2 > 0 or $0 > 0 and $3+$4 > 0  %} 
Yes
{% else %}
No
{% endif %}

By changing the assigns for my variables I checked if it is working properly. Your code should be like:

{% if period.reconciliations.reserves_and_dividends.results.distributeddividends > 0 and period.reconciliations.breakdownofprofit.custom.breakdownofprofit.nid1+period.reconciliations.breakdownofprofit.custom.breakdownofprofit.nid2 > 0  or period.reconciliations.reserves_and_dividends.results.distributeddividends > 0 and period.reconciliations.breakdownofprofit.custom.breakdownofprofit.tlcf1+period.reconciliations.breakdownofprofit.custom.breakdownofprofit.tlcf2 > 0 %}

Can you try it and let me know if this worked for you?

(P.S If it is possible, I would like to ask you to use English next time. The Silverfin Community is a place where technical Silverfin enthousiasts can find each other to get into specific questions on the Silverfin Templating Language or API. In order to achieve this, we will need all questions to be posted in English. Thank you in advance.)

Regards,
Michail

Hello michail,

Thanks for your answer.

I tried to code it in the way you showed it above but it doesn’t works.

Do you see a mistake in my code ?

{% assign $0 = period.reconciliations.reserves_and_dividends.results.distributeddividends %}
{% assign $1 = period.reconciliations.breakdownofprofit.custom.breakdownofprofit.nid1 %}
{% assign $2 = period.reconciliations.breakdownofprofit.custom.breakdownofprofit.nid2 %}
{% assign $3 = period.reconciliations.breakdownofprofit.custom.breakdownofprofit.tlcf1 %}
{% assign $4 = period.reconciliations.breakdownofprofit.custom.breakdownofprofit.tlcf2 %}

{% if $0 > 0 and $1+$2 > 0 or $0 > 0 and $3+$4 > 0  %}

Good morning @marnixcoudre,

I am not sure about this one but I think that variables like $0, $1, $2 etc are assigned in order to adapt a number. Can you try changing those variables with another word? For example distributeddividends instead of $0 and nid1 instead of $1. I used them like that for my example so I can change the numbers and try the calculations. If you do that, your code should look like:

{% assign distributeddividends = period.reconciliations.reserves_and_dividends.results.distributeddividends %}
{% assign nid1 = period.reconciliations.breakdownofprofit.custom.breakdownofprofit.nid1 %}
{% assign nid2 = period.reconciliations.breakdownofprofit.custom.breakdownofprofit.nid2 %}
{% assign tlcf1 = period.reconciliations.breakdownofprofit.custom.breakdownofprofit.tlcf1 %}
{% assign tlcf2 = period.reconciliations.breakdownofprofit.custom.breakdownofprofit.tlcf2 %}

{% if distributeddividends > 0 and nid1+nid2 > 0 or distributeddividends > 0 and tlcf1+tlcf2 > 0 %}

If it still doesn’t work don’t hesitate to reply back letting me know and I will simulate your code trying to find another solution for you.

Regards,
Michail