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

**URL:** <https://community.silverfin.com/t/formula-incorrectly-calculating-based-off-of-digits-within-a-number-preceding-comma/1919>\
**Category:** Templates\
**Created:** [September 15, 2020, 12:51pm UTC](https://community.silverfin.com/t/formula-incorrectly-calculating-based-off-of-digits-within-a-number-preceding-comma/1919 "2020-09-15T12:51:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhanley](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@jhanley](https://community.silverfin.com/u/jhanley)\
**Post date:** [September 15, 2020, 12:51pm UTC](https://community.silverfin.com/t/formula-incorrectly-calculating-based-off-of-digits-within-a-number-preceding-comma/1919/1 "2020-09-15T12:51:42Z")

</div>

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](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/2X/4/445e81d7e654f94557af15b7022ac7a9a76f7520.png)

This does not seem to be an issue when there is no comma in the value - see below: 750 - 800 = -50:  
 ![image](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/2X/6/6b3f86fcace03de2d9da561d87d0a0b902cb5df3.png)

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

```auto
{% 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

---

<div class="post-metadata">

**Author:** ![Ward\_Lostrie](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/ward_lostrie/32/1136_2.png) [@Ward\_Lostrie](https://community.silverfin.com/u/Ward_Lostrie)\
**Post date:** [September 15, 2020, 1:58pm UTC](https://community.silverfin.com/t/formula-incorrectly-calculating-based-off-of-digits-within-a-number-preceding-comma/1919/2 "2020-09-15T13:58:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jhanley](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@jhanley](https://community.silverfin.com/u/jhanley)\
**Post date:** [September 15, 2020, 2:25pm UTC](https://community.silverfin.com/t/formula-incorrectly-calculating-based-off-of-digits-within-a-number-preceding-comma/1919/3 "2020-09-15T14:25:50Z")

</div>

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

Works like a charm once you know how!

Joe
