Expressions in MAPublisher

From time to time I need to edit attributes in the MAPublisher MAP Attributes table. Typically this is for formatting the names of features before generating labels, but not always. Often I will figure something out, do the thing, move on, and then kick myself 6 months or 3 years down the road when I have to figure the same thing out all over again. I’m going to write them down here and maybe I won’t have to look them up in the future! And maybe it will help someone else.

Append a string if another string doesn’t already exist

I was working with the WPDA dataset and labeling a subset of the polygons. In this case I wanted to label all of the National Parks. Some of the values in the NAME field had “National Park” somewhere in the name, sometimes at the beginning, sometimes at the end.

Some values have “National Park”, others don’t

So, we need an expression that looks to see if the string “National” exists. If it does, leave the NAME value alone, if it doesn’t, then append “National Park” to the end of the existing value.

IF(CONTAINS(NAME,"National"),NAME,NAME & " " & "National Park")

This expression says:

(1) If the value in NAME contains “National”, (2) then replace with NAME (ie-leave it alone., (3) if it doesn’t contain “National”, then replace the value with the existing NAME value and append the string “National Park”.

Apply the expression via the “Apply Expression” option in the flyout menu of the MAP Attributes table:

And the features in question have the correct string, “National Park”, applied to them:

Leave a Reply

Your email address will not be published.