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.
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.
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.
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.
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.
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.
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.