How to sum things in database formatted as text?

I have an input which is formatted as text just to be able to insert a input mask so that it works like this:
Placeholder: 0,00
Type 1 : 1,00
Type 2: 2,10
Type 3: 3,21
type 4: 43,21
Type 5: 543,21

That is it. But in order to do that is requires that in this plugin the input is formatted as text.
But at some point I need to sum everything that is recorded in the database. Because its data type is text, not number, there is no option to select the “sum” function.

Any way to do this? I really wanted to keep the input mask as I described. Maybe another plugin or another way around. I really do not understand why in those inputs Bubble doesn’t treat number as a any sort of number but just as “decimals” or “integer”.

Either way is insuficient. Am I losing something here? Thanks

integer is a number

Decimals look like what you are using

All you need to do is decide if you expect people to add decimals or not…if they may do both decimals and whole numbers just select the type as decimal…if you do not expect users to add decimals, just select integer.

You can only do mathematical operators, like :sum on numbers, so you need to make the input either decimal or integer.

The idea of having the words Type 1: or Type 2: is not essential for them to be in the input the user types the numerical value into…you can just have them has text elements in front of the input for numbers.

I am not sure if you understood what I mean’t.

1.221,21 is a number but not a integer. Help me out.

Looks like a decimal

@jairocbastos I’m not entirely sure what you’re talking about here…

But if you’re storing numbers in the database, but your input value is a text “Type 1 : 1.00” (is that what you’re saying?) then just split the text by : and convert the last item to a number.

Although I’m not sure that is what you’re talking about (and if it is, I don’t understand why you’re doing that?)

Hi Adam.
I face two possibilities:
a) Data type: number. Then input: decimal. Decimal place 2. Need to sum everything afterwards. Cool - this works. however there is a friction for the client experience when typing 1234 number whatever in the input.

I’ll show how this follows:
Click on the input: placeholder turns to: 0,00
type 1: 1,00
type 2: 12,00
Then adjust to click with mouse pointer immediately after comma: type 1: 12,10
Then adjust to click with mouse pointer after comma in the last 0: type 1: 12,01

Anyway, this is terrible. I just wanted to have an “input mask plugin” ( or also input formatter ) so that it worked like I described. But in order to do that I’ve just found a plugin that works with only “text type”.

The second possibility is this:
B) When working with that plugin, the experience is as follows:

Placeholder: 0,00
Type 1 : 1,00
Type 2: 2,10
Type 3: 3,21
type 4: 43,21
Type 5: 543,21

However, in this way, data type is text and I need to sum everything afterwards. Not avaiable option. I tried this way because the experience of the input for the cliente is seamlessly effortless. Just type without worries in a continuos manner.
@adamhholmes @boston85719

I liked what you said about converting text to number. Maybe this helps. I’ll try it.

If you’re just asking how to convert a text to a number, you just need to use the :converted to number operator after the text value.

1 Like

That is the solution. Thanks!

1 Like

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