Any help appreciated. I am trying to write an expression that will create a label based on presence or absence of data across a number of fields.
I want the label to include the following:
- Location Name - from field
- IF ItemCount != 0 THEN add a new line with a text label and then the ItemCount value ELSE go to next item
There are 9 or more items.
eg for the Home location with 2 cars, 4 bikes, and 1 boat the label would look like:
However, if no bikes or boat, then the label would be as below with no extra lines:
The data fields are setup similar to this
- OID / LOCATION / CAR_count / BIKE_count / BOAT_count
Using Arcade I was able to build a multi-line label by using:
Concatenate([
$feature.LOCATION,
'Car: ' + $feature.CAR_count,
'Bike: ' + $feature.BIKE_count,
'Boat: ' + $featureBOAT_count],
TextFormatting.NewLine)
This works fine and outputs a count for all 3 types even when the count is zero. I need to find a way to only add a line when the count is greater than zero. This will simplify the map by reducing the entries in the labels when only 1 or 2 of the 9 (or more) data fields are present.
The solution doesn't have to be using Arcade, could be VBscript, JScript, or Python if you have an easy solution.
Many thanks, Pete