Jump to content

subtracting one number from another number


ehigginbotham

Recommended Posts

I have two data fields that have large numbers in them. I need to subtract one number from the other. they have two decimal places. This sounds simple enough, but I can't get it to work without FP doing some wierd formatting on the numbers, that gives me 17.00 instead of 16855.36.

its like it is rounding up the first two numbers.

Here is the rule as I have it currently.

 

var account = StringToNumber(Field("ACCOUNT-ENDING"))

var company = StringToNumber(Field("COMPANY-ENDING"))

var total = account - company

return FormatNumber("#####.##",total)

 

// the numbers in the data are

//ACCOUNT-ENDING = 66,442.44

//COMPANY-ENDING = 49,587.08

//the result of this function is 17.00

 

any idea what I am doing wrong?

Link to comment
Share on other sites

I think the comma is throwing off the calculation. Try this:

var account = StringToNumber(Field("ACCOUNT-ENDING")[color="Red"].replace(/,/g,"")[/color])
var company = StringToNumber(Field("COMPANY-ENDING")[color="red"].replace(/,/g,"")[/color])

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...