Decimal Places on Prices

The “number” field type truncates trailing zeros after a decimal place.

Eg. Price shows up as $5.5 instead of $5.50

Any idea how I can fix this???

Why not use the “currency” field type rather than the “number” field type.

That should solve it.

Because CURRENCY is not a data type that I can apply to a field.

text
number
number range
date
date interval
yes/no
file
image
geographic address

That is the extent of what I can use…

I just looked at my app and can use Currency for all types of fields.
Maybe you could make your app public and we can take a look at it.

Goodluck fixing it.

When displaying a number formatted as currency, set the decimal to 2. Your number values in the database won’t show up with trailing zeros, so if you need to display them, you’ll have to format the value with the proper currency setting as shown below.

Same principle applies for percentages… 5% is going to be saved as .05 in the database, but formatting it will allow you to display as “5%”


Gaby | Coaching Bubble

@romanmg

Gaby,

I’m following your instructions but isn’t quite working for me… The only significant difference from the example above is that my number comes trough an API call…

1- Set the field as “Number” on the API Connector

2- On my Data that “thing” is also set as a number
41%20AM

3-Configure “formatted as” like you instructed

4-As I’m setting the relationship between my Data thing and the API call the text is all in red even when I added the “formatted as” option like you did. Bubble gives me the following error:

What you think?

When you’re saving the value to the database, you just want to save the number without formatting. Once you format, you convert it to text, which is why it’s in red (number cannot equal text).

Only format the number when you want to display it on a page (in a text element or input) and leave the raw value as a number in your database.

1 Like

@romanmg tks, it worked perfectly!

Hi, I’m having the same issue with the numbers not converting properly. I thought I set all of the parameters correctly I am still getting multiple 0’s. In the example with the pictures, I want the value to be $720.00. In the database, the value is 72000. I’m using Stripe as my payment processor, do you think that has anything to do with it? Any help would be greatly appreciated! Thanks!

48%20PM
35%20PM


Stripe API handles amounts in cents, I suggest dividing by 100 when storing in your database.

1 Like

How would I do that?

Something like

Priced = Result of step 1’s Amount Charged / 100

Don’t forget to multiply by 100 when sending amounts to Stripe’s API.

Thank you so much!

Hi
I m a newbie,
where do you format the number?
Data?
Input?
I do not find decimal place ,separator,etc
only Currency
thx