Unless statement with percentage input

Hi,

I’m trying to make it so the second question only appears when the % entered is less than 100. I could get this to work when the input field was set as a ‘number’, but now I’ve changed it to a ‘percentage’ I’m not sure what to change to make it work. The relevant section of code copied below. Thanks

|File completion percentage at the date noted above
| {% input custom.completion.percentage as:percentage precision:0 %}
|{% unless custom.completion.percentage < 100 %}
{%else%}
{% newline %}
|Provide reason as to why not at 100%
|{% input custom.reason.why as:text placeholder:‘reason’ %}
{% endunless %}
{% newline %}
|Generate an export of the working papers, and save here, using the date noted above as the file name
|{% input custom.working.papers as:file %}
{% newline %}

@Megan

Thank you for your question.

A percent can be expressed as Decimal or fraction. For example:

  • As a percentage: 50%
  • As a decimal: 0.5
  • As a fraction: 1/2

100% is 1

System stores variables as numbers, it means 100% is stored as 1 (10% as 0.1, 1% as 0.01).

In your formula comparison should be with 1 instead of 100:

{% unless custom.completion.percentage < 1 %}

Please let me know if this works.

Jelena

Hi Jelena,

Thanks so much - it is now working exactly as it should be.

Nice and simple solution that I’ll know for next time.

Many thanks again,

Megan