Hi all,
I'm trying to label some features with data from various columns in the attribute table. I've been using VBScript to do this, with an expression such as:
[Column 1] &vbnewline& [Column 2] &vbnewline& [Column 3] &vbnewline& etc.
The problem I'm encountering is if one of the columns is empty or has a null value, the label skips a line where that columns label should be (see screenshot).
Is there a way to remove this space? This is my first time using expressions to display labels in this way, so I'm relatively unfamiliar with VPScript, Arcade etc.
In Arcade, you can check whether a field is empty before adding it to the string.
This example uses an array (fields) that contains the field name of each of your fields (line 2). The code loops through that array (line 4) and adds the value to an array (output) if the field's value is not empty (line 5). It uses the Concatenate function to return a string with all of the non-empty values in the output array on a separate line (line 7)
var output = [];
var fields = ["fieldName1", "fieldName2", "fieldName3"];
for (var field of fields) {
if (!IsEmpty($feature[field])) Push(output,$feature[field]);
}
return Concatenate(output, TextFormatting.NewLine);
Thanks for your response, I'll try that expression out this morning!