Today at work I was facing some challenges to Label the count values from attribute tables of the feature class. We have all the data stored in geodatabase that is server based. I wrote python code in label expression that did not work out. Challenge is I have a field whose value are repeating,and I want to plot those how many times these values are repeating. Please see below image, Attribute field example

On above image, I want to label A(2), B(2), C(3), D(1). So on the bracket it should show count values.

How to do with the feature class stored in geodatabse that is connection based?

1 Answer 1



def FindLabel ( [Label] ):
  mxd = arcpy.mapping.MapDocument("CURRENT")
  lyr = arcpy.mapping.ListLayers(mxd,"TARGET")[0]
  return '%s(%s)' %([LABEL],str(n))

is tested on shapefile:

enter image description here


enter image description here

  • Thank you For the code, I will test on the geodatabase and will update you. Code looks great. Dec 5, 2015 at 4:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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