For example, i have n count of polygons and little parts of it.

I want in field [Name] get string: "PNum1(1)".

where "1" - number of main polygon [Num], "(1)" - number of part of main polygon [Num_app].

In field calculator i use this expression: "PNum" & [Num] & "(" & [Num_app] & ")".

enter image description here enter image description here On the screenshot is Pnum 13(),Pnum 10() What i need write in expression if [Nomer_app] is Null and "(", ")" must do not shown (when main polygon don`t have any parts the string looks: Pnum2())?

  • I think we may need you to include some screenshots. By "n count of polygons and little parts of it" are you perhaps meaning a feature class with multipart polygons? – PolyGeo Nov 13 '15 at 6:13
  • What does the attribute table corresponding to the polygons in your screenshot look like? – PolyGeo Nov 13 '15 at 6:27

If I understand your question correctly, you can use this python expression to label your polygons. Empty strings, None (Null), False, 0 (+ others) all evaluate to False so you devise two separate strings.

Here's what it would look like in the label expression (don't need to use advanced):

"PNUM {}({})".format([num], [num_app]) if [num_app] else "PNUM {}".format([num])

If you wanted to use vbscript, this should work. There's probably much prettier and simpler ways, though (need advanced checkbox):

Function FindLabel ([num], [num_app])
  If IsNull([num]) Then
    FindLabel = "PNum " & [num]
    FindLabel = "PNum " & [num] & "("&[num_app]&")"
  End If
End Function

I'm assuming your fields are already populated with polygon and part numbers.

For field Calculator:

"PNUM {}({})".format(!num!, !num_app!) if !num_app! else "PNUM {}".format(!num!)
  • Thanks a lot. Very good.All things work.But only for labeling. – Jannik Nov 13 '15 at 8:12
  • Firstly i tray to use it in table to change field value by field calculator. Wrong. Its work only for Labeling. What expression i need? – Jannik Nov 13 '15 at 8:24
  • What expression to change field [Name] in table? With the same conditions like Labeling operation that you suggested earlier – Jannik Nov 13 '15 at 9:31
  • 1
    @Jannik, label expression fields are enclosed with square braces. To use the same in Field Calculator, paste the python code (make sure the parser is python) and change the square braces to exclamation points. – Paul Nov 13 '15 at 16:40
  • 1
    @Jannik, I'd recommend searching for ways to increment a field. – Paul Nov 16 '15 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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