I was trying to figure out a way to create an if clause to label some disposition features using the "company" attribute. Unfortunately, there isn't much space on the map so I had to truncate the field and use the first word (no abbreviation field in the data either). The problem is that sometimes, the company name's first word can be something really short: 2 or 3 letters. So, I made an expression that uses an if clause to display 2 words from the company name, if the first one is 3 characters or less.
I feel the expression might be a bit too long/complicated/"not elegant". Does anyone have a nicer way of doing this?
var A = Split($feature.company," ")[0]+" "
var B = Split($feature.company," ")[1]+ "\n"+$feature.disp_num
var C = Split($feature.company," ")[0]+ "\n"+$feature.disp_num
var lttr1 = $feature.company[0]
var lttr2 = $feature.company[1]
var lttr3 = $feature.company[2]
var lttr4 = $feature.company[3]
if (lttr1 ==" ")
A+B
else if (lttr2 ==" ")
A+B
else if (lttr3 ==" ")
A+B
else if (lttr4 ==" ")
A+B
else
C