def FindLabel ( [FIBER_ASSEMBLY_UNITS_ASSEMBLY_UNIT], [POLE_PRIKEY] ): if long( [POLE_PRIKEY] ) = long( [POLE_PRIKEY] ): return [FIBER_ASSEMBLY_UNITS_ASSEMBLY_UNIT] + '\n' + [FIBER_ASSEMBLY_UNITS_ASSEMBLY_UNIT] + '\n' + [FIBER_ASSEMBLY_UNITS_ASSEMBLY_UNIT] else: return [FIBER_ASSEMBLY_UNITS_ASSEMBLY_UNIT]
Solved! Go to Solution.
if long( [POLE_PRIKEY] ) = long( [POLE_PRIKEY] ):
def FindLabel([FIBER_ASSEMBLY_UNITS_ASSEMBLY_UNIT], [POLE_PRIKEY]): if long( [POLE_PRIKEY] ) == long( [POLE_PRIKEY] ): labelText = '{0}\n{1}\n{2}'.format([FIBER_ASSEMBLY_UNITS_ASSEMBLY_UNIT], [FIBER_ASSEMBLY_UNITS_ASSEMBLY_UNIT], [FIBER_ASSEMBLY_UNITS_ASSEMBLY_UNIT]) return labelText else: labelText = [FIBER_ASSEMBLY_UNITS_ASSEMBLY_UNIT] return labelText
There is no way I can think of to reference multiple rows as a single label using label expressions.
def FindLabel([QS], [TWP]): val_list = [] keyField = "TWP" keyVal = [TWP] field = "QS" fieldVal = [QS] layer = "ats" with arcpy.da.SearchCursor( layer, field, "{0} = {1}".format(keyField, keyVal)) as cursor: for row in cursor: val1 = row[0] val_list.append(val1) returnVal = "\n".join(val_list) return returnVal
I possibly found a way to do it. Not all that fast though. You'll have to change all the field names to your data. It will return a label for every feature populated by every item in your target field that match the key field value.
def FindLabel( [POLE_PRIKEY] , [FIBER_ASSEMBLY_UNITS_ASSEMBLY_UNIT] ): val_list = [] keyField = "POLE_PRIKEY" keyVal = [POLE_PRIKEY] field = "FIBER_ASSEMBLY_UNITS_ASSEMBLY_UNIT" fieldVal = [FIBER_ASSEMBLY_UNITS_ASSEMBLY_UNIT] layer = "TEST" with arcpy.da.SearchCursor( layer, field, "{0} = {1}".format(keyField, keyVal)) as cursor: for row in cursor: val1 = row[0] val_list.append(val1) returnVal = "\n".join(val_list) return returnVal