For example, I'm calling a number into the infobox using the following code:


The value is 1155000, but I want it to display as 1,155,000.

Is there a way to do that without having to reformat the column as a string and adding the commas that way?


I recommend using PostgreSQL instead of {{mustache}}. First, create a new column. Rename it as formatted. Then, run the following SQL query to format your numeric field (med_value) as you wish:

  formatted = TO_CHAR(med_value, '999,999.99')

Finally, add an infowindow showing the formatted field and voilá!

enter image description here

Here you have more info about TO_CHAR function.

  • 1
    While this works, it's not necessarily a great idea to create derived columns just for formatting -- easy to forget on data update --and this is the kind of thing you should be delegating to moustache or even css. stackoverflow.com/questions/6114435/… – John Powell Aug 1 '16 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.