Hide Decimals (WITHOUT Rounding)

Hi Bubble People!

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:

Image 001

Any advice?
Thanks for your help.

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.

Hi @nico.dicagno ,

Thanks for the help!

Our payment calculator shows more than 50 calculations / input fields (table of 5 columns and 10 rows).

Do you believe there is an easier way instead of having both calculations (display and custom state)?

Thanks.

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.

Hey @nico.dicagno ,

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?

Thanks again for you time and support.

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.

Thanks @nico.dicagno ,

Everything very clear.

Happy holidays!

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.