What is label expression for formatting a number to have thousands separator and decimals?

6617
6
Jump to solution
11-25-2014 02:30 PM
RickWarner
New Contributor III

I can do this in the  table, but would rather have ability in the labeling of the map.

0 Kudos
1 Solution

Accepted Solutions
AnthonyGiles
Frequent Contributor

RIck,

If you are after python specific code then you can use the str.format(), see examples here:

Python String Format Cookbook | mkaz.com

View solution in original post

6 Replies
AnthonyGiles
Frequent Contributor

Rick,

Have a look at this article:

Make Numeric Labels More Readable

You could also use the FormatNumber function in vbscript:

http://www.esri.com/news/arcuser/1104/files/vbscript_label.pdf

Regards

Anthony

KevinBell
Occasional Contributor III

def makeMoney(n):

    import locale

    locale.setlocale(locale.LC_ALL, '')

    S = locale.currency(float(n), grouping=True)

    return S

0 Kudos
RickWarner
New Contributor III

Thank you Kevin,

Is there a way to remove the decimals from the currency, but have the thousands separator. I’m dealing with Sales Price of real estate and there usually no decimal place, ie. 100,000 for a home.

Richard

0 Kudos
KevinBell
Occasional Contributor III
0 Kudos
AnthonyGiles
Frequent Contributor

RIck,

If you are after python specific code then you can use the str.format(), see examples here:

Python String Format Cookbook | mkaz.com

Luke_Pinner
MVP Regular Contributor

A one liner (modified from code on Stack Overflow😞

"{:,}".format(int(value))