We are creating a payment calculator where it needs exact values to obtain the final result. We are using currency input fields for calculations.
We need to hide decimal numbers WITHOUT rounding the numbers. I mean, if the value is $1.2 it should show as $1 but the value for calculations in other input fields need to use $1.2 to obtain the exact final value needed.
We have tried formatting the number to currency and 0 decimal places. However, the following error appears:
You are setting the content format of the input as Currency, however its still expecting a number value.
In your dynamic expression you are formatting the number as a currency, which turns it into a text/string.
You are essentially trying to format the number as a currency two times, which doesnât work.
Go into your :formatted as settings, and remove the currency format, set it to a number. You will then have to :convert to number because the input expects a number, not a string.
This is essentially the same as using the :round operator.
There is no way of having a âdisplayâ value and an âactualâ value on an input. If you reference a value in one of your workflow steps by using'Input's value', this will always return the value being displayed on the input.
But donât worry, instead of referencing the inputâs value, use a custom state. Set it to the expression value, and then reference the custom state in any calculation. If you do this, you can format the input value however youâd like without worrying of it affecting your calculations.
Use the âWhen input value changesâ to update the custom state if the input value changes.
You could have two input elements. One being your formatted input, and one being your value-holder.
The formatted one would be visible to the customer, formatted however you like, but never referenced.
The value-holder would not be visible to the customer, not formatted, and would be referenced in calculations.
I understand your solution and it totally makes sense.
Before I start implementing it, I would like to know what is the difference between âRounded toâ and âFormatted asâ for decimal numbers. On both cases the numbers will be rounded? On both cases will the calculations be made using rounded (displayed) or complete numbers?
The main difference between the two is that â:formatted asâ outputs a text/string, while â:rounded toâ outputs a number. So in the case of your input values you will need to use :rounded to, because you set those inputs to require a number.
Both of these operators actually change the value, so if you are using them for calculations, they would be done using the rounded (displayed number).
Because of the above reason, you should not use any of the operators on you âvalue-holderâ input, as you want to do calculations with the complete number.
You will also notice that you cant really do calculations with âformatted asâ because you cannot do numerical calculations with a text/string.