NUMBER function omits decimal

Hi there.

I’m starting here and right in the begining I encounter my first obstacle.

I have an user input for a currency value that could include decimals.
In LOGIC I use an OnBlur event with the following formula to convert the input to something similar to a currency value:

FORMAT_LOCALIZED_DECIMAL(NUMBER(pageVars.input_value), “de”, 2, 2)

The problem is that NUMBER returns the input in number format, but omits the decimals. So if I input 1234,56 it returns 1234 and then formats it to 1.234,00.

I’ve tried a lot of things now and I’ve searched all around (including Google) and the answer is nowhere to be found.

Hope you guys can help me.
Thanks.

Hi! Try using a dot instead of a comma for the NUMBER function (docs). If the user input uses a comma, you can use REPLACE_ONE to change it to a dot (docs).

Right. That worked. Howcome It didn’t occured to me?

I just adapted the formula this way:

FORMAT_LOCALIZED_DECIMAL(NUMBER(REPLACE_ONE(pageVars.input_value, “,”, “.”)), “de”, 2, 2)

Sure it isn’t a pleasent thing to read but it works. If someone has a better way to implement the solution, please tell.

I also made some changes in logic to remove the thousands separator (on focus) so it is a whole number again, editable in the input field and understandable in the following calculations.

Thanks for your imediate response.

2 Likes