I managed to find a workaround that worked for me. I had a set of parks with Yes/No values on attributes like BASEBALL, FOOTBALL, etc. I wanted to show what are the available sports in every park, but without blank lines. So basically here are the steps :
- Convert the Yes/No values into strings and null values with IIf statements, but add a separator ( like ; )
- Concatenate into a big string
- Split the big string into an array using the separators used in step 1
- Count the number of sports for each park
- Use some if/else if conditions to concatenate everything nicely (with new lines) for each specific number of sport.
Here is the code :
_________________________________
var arr = Split(
Concatenate(
IIf($feature.BASEBALL == 'Yes', ' • Baseball;', Null),
IIf($feature.BASKETBALL == 'Yes', ' • Basketball;', Null),
IIf($feature.FOOTBALL == 'Yes', ' • Football;', Null),
IIf($feature.SOCCER == 'Yes', ' • Soccer;', Null),
IIf($feature.TENNIS == 'Yes', ' • Tennis;', Null),
IIf($feature.VOLLEYBALL == 'Yes', ' • Volleyball;', Null)
),";");
var number = Count(arr);
if (number==1){
return '*** No sport in this park ***';
} else if (number==2){
return Text(Concatenate((arr[0]) + TextFormatting.NewLine + (arr[1])));
} else if (number==3){
return Text(Concatenate((arr[0]) + TextFormatting.NewLine + (arr[1]) + TextFormatting.NewLine + (arr[2])));
} else if (number==4){
return
...
...
} else {
return 'other';
}