Calculating the sum of local strings

Hi, so I am trying to calculate and display the sum of two local string values.

For example:
Adding 13,000 and 10,000 to show 23,000

I can get it to work if I have not added the commas string, so if I use the formula [[LVAR1 + LVAR2]] on regular number inputs like 10000 and 12000 it works. But the same formula will not work once a comma has been added to the number.

Can anyone help me?

If there might be commas in the strings, then remove the commas:

[[LVAR1.replace(',','') + LVAR2.replace(',','')]]

This replaces the commas with nothing, removing them.

Hi!

Looks like Nathan beat me to it.

The following will put the comma back into the sum. The multiplication by 1.0 is there to force the sum into the Number type; otherwise, it will interpret the number as a date and use the date form of the toLocaleString() function.

[[ (( VAR1.replace(’,’, ‘’) + VAR2.replace(’,’, ‘’) )*1.0).toLocaleString()]]

Thanks so much it worked :grinning:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.