Decimal places problem in Label Display

7062
7
10-10-2014 10:22 AM
RobertThomson
Occasional Contributor II

For some reason one of my label expressions [year] is showing 6 decimal places when there should be none.  A similar label [Age] shows properly without any decimal places.  Both field are defined the same as numeric.

Expression:

[Year]&" "& [Project] &" "& [Age]&" yrs old"

decimal.JPG

0 Kudos
7 Replies
WendyHarrison
Esri Contributor

Hi Robert,

could you send more information about the fields you're using to label?  data type? length? were they preexisting fields from 10x? or were they newly added in pro?

thanks

Wendy

0 Kudos
Greg_Yetman
Occasional Contributor

I just ran into the same problem in ArcGIS Pro 1.2. I imported a layer from an ArcMap mxd and enabled labeling (basic label engine) to show a Double field from a feature class in a file geodatabase, which was created in Desktop 10.3.1. When I go to Symbology-->Advanced-->Format Labels and change the number of decimals to be shown to 2 the labels do not change. Screen shot below.

0 Kudos
WendyHarrison
Esri Contributor

Hi Greg - on the Symbology pane you're setting the labels for the layer in the Contents pane.  To set labels on the features in the map you need to use the Label Class pane and set a label expression as you've done below with python.

Wendy

0 Kudos
BenjaminMittler
Occasional Contributor III

As a temporary workaround this should work:

left( [Year] ,4) &" "& [Project] &" "& [Age]&" yrs old"

Greg_Yetman
Occasional Contributor

Thanks, useful workaround. Using python worked for me:

round(float([Percent_diff]),2)

DanPatterson_Retired
MVP Emeritus

As a demo

>>> Year = 2016

>>> Project = 'Some'

>>> Age = 3

>>> "{} {} {} yrs old".format(Year,Project,Age)

'2016 Some 3 yrs old'

>>>

The python mini-formatting language handles conversions and you can specify formats.  In the examples above, you can even use field names by enclosing them with exclamation marks should you ever need to pull stuff from a field (ie !Year! etc)

FC_Basson
MVP Regular Contributor

You could also try setting the number of decimal places to 0 in the field properties.

0 Kudos