Select to view content in your preferred language

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

7058
6
Jump to solution
11-25-2014 02:30 PM
RickWarner
Occasional Contributor

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
Honored 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
Honored 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
Deactivated User

def makeMoney(n):

    import locale

    locale.setlocale(locale.LC_ALL, '')

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

    return S

0 Kudos
RickWarner
Occasional Contributor

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
Deactivated User
0 Kudos
AnthonyGiles
Honored 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))