# Give a value "0" in a cel of a template in stead of "-"

Hi,

How can I give a value 0 in stead of “-” when the calculation is as follows:

``````{% newline %}
| % Gealloceerde kosten arbeiders
{% assign percalloarb = arb/(arb+bed) %}
| {{ percalloarb | percentage }}
{% newline %}
| % Gealloceerde kosten bedienden
{% assign percallobed = bed/(arb+bed) %}
| {{ percallobed | percentage }}
{% newline %}
``````

When the value of local variabel “arb” and/or “bed” equals “0” the the result “-” is given in for “percallobed” or “percalloarb”.
I’m trying to make an if statement as follows:

``````| {% if percalloarb == "" %}{{ 0 | percentage }}{% else %}{{ percalloarb | percentage }}{% endif %}
``````

but this doesn’t seem to work:

I cant directly find the correct code.

I’ve found a way to resolve my problem, but probably there is a beter way:

``````{% newline %}
| % Gealloceerde kosten arbeiders
{% if arb < 0 or arb > 0  and bed < 0 or bed > 0 %} {% assign percalloarb = arb/(arb+bed) %} {% else %} {% assign percalloarb = 0 %} {% endif %}
| {{ percalloarb | percentage }}
{% newline %}
| % Gealloceerde kosten bedienden
{% if arb < 0 or arb > 0  and bed < 0 or bed > 0 %} {% assign percallobed = bed/(arb+bed) %} {% else %} {% assign percallobed = 0 %} {% endif %}
| {{ percallobed | percentage }}
{% newline %}
``````

Hi AlexanderDB

normally the ‘-’ should only appear when both bed and arb are 0. Which makes sense, because in that case you are dividing by 0. Can you test if it is only in that case and not when only bed or arb are 0?

You can try to make an unless-statement around your code, what will look like this :

``````{% unless arb == 0 and bed == 0 %}
{% assign percalloarb = arb/(arb+bed) %}
| {{ percalloarb | percentage }}
{% newline %}
| % Gealloceerde kosten bedienden
{% assign percallobed = bed/(arb+bed) %}
| {{ percallobed | percentage }}
{% endunless %}
``````

Kind regards
Sofie