Select to view content in your preferred language

Label Expression HELP!

2127
5
Jump to solution
01-16-2013 04:38 AM
CaraMays
Deactivated User
Below is my current expression that is labeling landowner names, abbreviated to the first letter of their first name with a comma dividing the first initial with the last name.

I would like to add the PID directly below the name. I would like the PID to have the same label characteristics as the name or "PartyName" does.

Can anyone else where to add the PID and how to correctly format this. THANKS!

Function FindLabel ( [PartyName] )
if InStr( [PartyName] , ",") > 0 Then
myArray = Split( [PartyName] , ",")
FindLabel = myArray(0) & ", " & LEFT(Trim(myArray(1)), 1) & "."
ElseIf Len( [PartyName] ) > 13 Then
FindLabel = Left([PartyName], 13)
Else
FindLabel = [PartyName]
End If
End Function
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
T__WayneWhitley
Honored Contributor
Fair enough, do something like the following, with the Python parser:
def FindLabel([PartyName], [PID]):  Party, PID = [PartyName], [PID]  YourLabel = ''  if ',' in Party:   Party = Party.split(',')   YourLabel = Party[0].strip() + ', ' + Party[1].strip()[0:1] + '.'  elif len(Party) > 13:   YourLabel = Party[0:13]  else:   YourLabel = Party  YourLabel = YourLabel + '\n' + PID  return YourLabel


More info is in the webhelp here:

Building label expressions
Desktop » Mapping » Adding text to a map » Displaying labels
http://resources.arcgis.com/en/help/main/10.1/index.html#/Building_label_expressions/00s800000027000...

View solution in original post

0 Kudos
5 Replies
T__WayneWhitley
Honored Contributor
You posted the same question here:
http://forums.arcgis.com/threads/75326-Label-Expression

So do you want the equivalent expression in python?  I think it doesn't matter really what parser you use, but maybe you're just short on details?  For example, if you want to introduce values from another field, you have to use the field name as it appears in your table.  Is your parcel identifier field name PID?...is it numeric or text?

You'd get much better cooperation from these forums if you are attentive to such details, don't ask duplicate questions, etc., and enter code properly formatted-- select your code block and use the '#' button to auto-enter the CODE tags, or enter them 'manually', typing after your code block and
 before...
0 Kudos
CaraMays
Deactivated User
I was aware that I posted the same question in another forum. That thread has since been deleted as it should have been before I posted it again in the python forum. I was directed to ask my question in the python forum rather than there I initially posted it. There are people who do not have interest in some fields therefore are not as attentive to other forums.

My PID field is a text field. I listed my parcel identifier as named PID in the my original thread.

I wasn't aware of the correct way to enter a code, this is exactly how I wrote the label expression in my layer so I guess I hoped it would be enough for people with experience in scripting to understand.
0 Kudos
T__WayneWhitley
Honored Contributor
Fair enough, do something like the following, with the Python parser:
def FindLabel([PartyName], [PID]):  Party, PID = [PartyName], [PID]  YourLabel = ''  if ',' in Party:   Party = Party.split(',')   YourLabel = Party[0].strip() + ', ' + Party[1].strip()[0:1] + '.'  elif len(Party) > 13:   YourLabel = Party[0:13]  else:   YourLabel = Party  YourLabel = YourLabel + '\n' + PID  return YourLabel


More info is in the webhelp here:

Building label expressions
Desktop » Mapping » Adding text to a map » Displaying labels
http://resources.arcgis.com/en/help/main/10.1/index.html#/Building_label_expressions/00s800000027000...
0 Kudos
CaraMays
Deactivated User
Got it! Thank you so much for your help. 🙂
0 Kudos
T__WayneWhitley
Honored Contributor
Terrific...!
Now if you would, please make this post as answered, thank you.

EDIT:  Please 'mark' this post as answered is what I meant to write... if unfamiliar with the controls, use what I call the 'toggle' button in the upper right margin beside the post.  The 'check mark' means 'answered', otherwise you can award points by 'toggling' the arrows.
0 Kudos