How can I convert a string to a number so I can perform arithmetic calculations?
Page 1 / 1
HI,
If you have a digit, it should not be an issue, otherwise have a look at the StringFormatter.
The StringFormatter is the way to go as Itay suggests...
You can also consider the @Evaluate function to allow string based transformers to consider the value as a number, like:
@Evaluate(<STRING>)
Yes, in general FME will just automatically convert any string to a number when it needs to. You can do this with the new String Editors that are part of any parameter (click on the down-arrow to the right, and you'll see the string/math editors there) -- there are always "math functions" there and you can just refer to attributes inside of the math functions -- for example @double(@Value(myAttr)) -- all possibly by drag and drop.
When handling floating point numbers with international source data, there can arise a situation where FME is unable to convert a string to a number if the decimal delimiter in your input data differs from the one defined on your system. Notably, the decimal delimiter is "," (comma) in some regions and "." (point) in others.
To resolve such problems, use a StringReplacer to set the correct decimal delimiter before doing arithmetic operations, that will usually take care of it.
David
If StringFormatter doesnt work with integers an alternative is to use an AttributeRounder before ExpressionEvaluator round to 1 or 2 dp, then round back to 0 after the ExpressionEvaluator.
Yes, in general FME will just automatically convert any string to a number when it needs to. You can do this with the new String Editors that are part of any parameter (click on the down-arrow to the right, and you'll see the string/math editors there) -- there are always "math functions" there and you can just refer to attributes inside of the math functions -- for example @double(@Value(myAttr)) -- all possibly by drag and drop.
it works !!! thanks