Rounding numbers

Dear,

I would like to round my calculation to an integer (i.e. 0,6 turns into 1; 0,44 turns into 0).

I already tried the ceil and the round function but it does not seem to work.

Can somebody help me with this matter?

Kind regards,

Marnix

{% input custom.some.thing as:integer %}
{{ custom.some.thing | integer }}

1 Like

Dear Thijs,

I’m actually having a similar issue. However it is not solved by your solution.

I have for example the value 10.000,45, if I use the as:integer modus I get 10.000. However I would like to have 10000, so stripped from all β€œ,” and β€œ.”. Which function could I use than?

Kind regards

Glenn

Hi Glenn

After using the integer, you can use the following liquid tag:

{{ value | replace: β€˜.’, β€˜β€™ }}

This should give you the appropriate result.

Kind regards

Sam

Dear Sam,

Thanks for the answer, however it does not do quite the trick I was expecting.

Let me give you some background:
In template 1 I’m inputting my variables:
{% assign $1 = 0 %}
{%=$1+ input custom.some.thing1 as:integer %}
{%=$1+ input custom.some.thing2 as:integer %}
{%=$1+ input custom.some.thing3 as:integer %}
{% result β€˜result1’ $1 %}

For example my input was: 10, 5 and 5.05

In my export file I used following code
{{period.reconciliations.handlereconciliation.custom.some.thing1 |replace: β€œ.” β€œβ€}}
{{period.reconciliations.handlereconciliation.custom.some.thing2 |replace: β€œ.” β€œβ€}}
{{period.reconciliations.handlereconciliation.custom.some.thing3 |replace: β€œ.” β€œβ€}}
{{period.reconciliations.handlereconciliation.results.result1 | integer}}

This is my output:
100
50
505
20

What I should get is:
10
5
5
20

Could you help me out, please?

Kind regards,

Glenn

Hi Glenn

This will solve it:

{% input custom.some.thing as:integer %}
{{ custom.some.thing | integer | replace:".","" }}

Kind regards
Sam

1 Like

Hi Sam,

This does indeed do the trick.

I had tried before {{custom.some.thing | integer replace:".",""}} However that gave me an error. I did not know it was necessar to use both times the |-function. Therefore I thought it was not possible.

Kind regards,

Glenn

Indeed, Every filter needs its own pipe :slight_smile:

Glad I could help and good luck with your templates.