Currency formatting without :formatted as or :find and replace

I have a list of prices in a table that I’d like to sort. Right now they’re just integers but I’d like to add commas to make them more readable. I’m able to handle the $ sign using BBCode (${{value}}), but I don’t know what to do for commas.

Here’s the problem: if I use :formatted as, the numbers are evaluated as texts. In that scenario, when the user goes to sort them low to high, a number like $100,000 will come before $25,000 instead of being sorted numerically. I have a handy regex that can add commas, but I run into the same problem as the numbers are then evaluated as text.

What should I do here?

Hey Sydney,

I suggest showing your users one thing and doing the work on another thing. Basically, have the display be a formatted: currency yet have it sort it its natural state as an integer.

What happens if you use the :converted to number operator after the formatted operator?

Screen Shot 2021-09-18 at 11.56.27 PM

Learn More

Boston85719 is an expert Bubbler with a decade experience as an educator. Real name Matthew, he has been actively building SaaS apps, marketplace apps, scheduling apps and more for clients, himself and for sale as templates.

As an official Bubble Bootcamp Instructor, he leads Bubble Bootcamps on a regular basis.

Always willing to offer advice via the Bubble Forum, Matthew also offers Private Personal and Group Training Sessions.

Through his site, NoCodeTrainer, Matthew provides a range of tutorials with editor access to help you jumpstart your Bubble development.

Always accessible you can send Matthew a private message via the forum or send an email directly with your requests.

Be sure to checkout the Stripe Integration Course when you are ready to integrate Stripe payments to start monetizing your application via product sales or subscriptions.

Stripe Integration Course

NoCodeTrainer.com

Hi @na811, thanks for the reply. I should’ve mentioned I actually tried this. Even if the value is stored as a number in the db, the moment it’s displayed as currency, Bubble treats it as text. It’s then sorted as a text, so $40,000 would be sorted after $100,000 (low to high) despite being the lower amount.

Thanks for the reply, @boston85719. In this scenario, the price is displayed (and sorted) as a number, but the commas are eliminated which makes it more difficult for the user to read.

Can you share screenshots of your repeating group and how you are sorting? I just tested what you are trying to do and sorting works as it should even when the value is formatted as a currency.

Here are the screenshots of my RG and Text box


I reread your initial post and just noticed you bring up BBcode. Bubble makes it easy and lets you format numbers as currency via the :formatted as > Number type: Currency. Your attempt at making it a currency via BBcode is turning it into text.

@na811 One more clarification I forgot to mention: I’m using Thimo’s Table/Grid plugin, not a Bubble RG. Not sure if that makes a difference.

Screen Shot 2021-09-19 at 10.32.35 PM


Screen Shot 2021-09-19 at 10.48.21 PM

This will ensure that the prices are sorted accurately. I can add a dollar sign in the BBCode without it turning into text, but then the numbers lack commas.

Screen Shot 2021-09-20 at 1.17.23 AM

This one is formatted correctly, but doesn’t sort properly.

Hi @sydney22 I’m having the exact same issue with the exact same plug in. Did you manage to find a solution?

Unfortunately, no. It would be great if the plugin could recognize the dollar sign and sort accordingly like Google Sheets or Excel although it would depend on the library’s capabilities. Best bet might be to PM Thimo or bring this issue over to the Table/Grid thread.

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