Formula incorrectly calculating based off of digits within a number preceding comma

Hi,

I have an issue with one of my templates, where my formula is incorrectly calculating based off of the digits within a number preceding a comma - see below: 1,000 - 800 = -799
image

This does not seem to be an issue when there is no comma in the value - see below: 750 - 800 = -50:
image

Are you able to advise what I may be missing from my code?

{% stripnewlines %}
| **Cost**
| **£**
{% newline %}
|--------
|--------:
{% newline %}
| Rate (£/hour)
| {% input custom.hourly.rate as:integer placeholder:"-" %}
{% newline %}
| Hours
|_{% input custom.budgeted.hours placeholder:"-" %}_
{% newline %}
{% assign budgeted_cost = (custom.hourly.rate*custom.budgeted.hours) | integer %}
|**Budgeted cost**
|**{{ budgeted_cost }}**
{% newline %}
| Actual cost
|_{% input custom.actual.cost as:integer placeholder:"-" %}_
{% newline %}
{% assign variance = budgeted_cost-custom.actual.cost %}
|**Variance**
|_{{ variance | integer}}_
{% endstripnewlines %}

Many thanks
Joe

Hi @jhanley,

The problem is that you assign the value to ‘budgeted_cost’ as an integer. The solution is to delete the pipe with “integer” in the assignment of ‘budgeted_cost’. To display the ‘budgeted_cost’ correctly, you should put the pipe with integer behind ‘budgeted_cost’ when printing it:

{% stripnewlines %}
| **Cost**
| **£**
{% newline %}
|--------
|--------:
{% newline %}
| Rate (£/hour)
| {% input custom.hourly.rate as:integer placeholder:"-" %}
{% newline %}
| Hours
|_{% input custom.budgeted.hours placeholder:"-" %}_
{% newline %}
{% assign budgeted_cost = (custom.hourly.rate*custom.budgeted.hours) %}
|**Budgeted cost**
|**{{ budgeted_cost | integer }}**
{% newline %}
| Actual cost
|_{% input custom.actual.cost as:integer placeholder:"-" %}_
{% newline %}
{% assign variance = budgeted_cost-custom.actual.cost %}
|**Variance**
|_{{ variance | integer}}_
{% endstripnewlines %}

Hope this is what you are looking for?

Kind regards,
Ward

Thanks @Ward_Lostrie, this is exactly what I was looking for.

Works like a charm once you know how!

Joe