ArcMap sometimes ignores labeling expression
This is because you try to use >
as a character in your label, as well as for formatting/programming your label. Nothing wrong with that, it's how it works. But if you want to use those characters in your label you need to escape them.
Instead of the actual characther you need to use <
(<), >
(>) and &
(&).
An alternative approach is to use label classes. Then you can have SQL queries instead of your IF statements, which IMO is easier to control.
I think you are mixing numbers and text. What type of field is vollkorrekt?
As it is now, you are comparing the value to a string, i.e. [vollkorrekt] >= '1'
. The comparison is therefore alphabetical instead of numeric, meaning that '19' is smaller than '5', but bigger than '1'.
If the type of the field is numeric, you only have to remove the single quotes: if [volkorrekt] >= 5:
etc.
If the type of the field is text, you have to convert the value to a float: if float([volkorrekt]) >= 5:
Here's the complete code, modified to increase readability:
def FindLabel( [volkorrekt] ):
value = float( [volkorrekt].replace(',', '.' ))
if value >= 5:
size = 20
elif value >= 2:
size = 14
elif value >= 1:
size = 8
else:
return ""
return "<FNT size='{0}'>{1}</FNT>".format(size, value)