Can i eliminate empty values using arcade in my pop up?

18365
18
05-08-2019 12:07 PM
KevinMilton
New Contributor III

I am attempting to create a conditional arcade expression that will list all of the fields that do not have a null value with an individual label and not show the field at all if the field is null. My current expression is below.

if (IsEmpty($feature.ABARTA_WI)){
return ""
} else {
return "Abarata: "+$feature.ABARTA_WI
}

This expression works in that it does not show the label or null value, but in the ArcGIS Portal pop up, it leaves an empty line for each one that is null, and i need it to not be there at all so the pop up is clean. As you can see below, this is creating empty lines in the popup. 

I would prefer the popup to display something like below, eliminating the empty lines.

Chief: 0.28

Chief WI MKR: 0.28

Enerplus: 0.3

arcade expression‌ arcade pop-ups‌conditional pop ups‌

Any help would be greatly appreciated.

Thank you

18 Replies
XanderBakker
Esri Esteemed Contributor

You can, but it will require multiple expressions and some html to do this (if you want to show it using html). Or you can create a larger expression that constructs the text to display and omits empty values. 

0 Kudos
KevinMilton
New Contributor III

Well I need this popup to look professional so this is what i need to do. Can you provide further information on what that larger expression would look like?

0 Kudos
MarkBockenhauer
Esri Regular Contributor

Using something similar to what you have, you could use an approach like this.

{expression/expr1}

var a = $feature.notes
var b = $feature.popper
var attributes = ""
If (!IsEmpty($feature.notes)){
attributes = a + TextFormatting.NewLine + b
}
else {
attributes = b
}
return attributes

If Feature notes attribute is not Empty  Show both attributes.

Else show one attribute

Mark

rbasgall
New Contributor

I was looking all over for a solution that I could only display non null field values with the field alias and ended up combining a few different things I found. 

var features = FeatureSetByName($map, 'CTP_Roadway_Observations', ['*'], false);
var aDict = Schema(features);
var aArray = aDict["fields"];
var output;
for (var i in $feature){
    if (!IsEmpty($feature[i])) {
        for(var j in aArray) {
            var dict = aArray[j];
            if (dict['name'] == i){
                output += dict['alias'] + ": " + $feature[i] + TextFormatting.NewLine + TextFormatting.NewLine;
            }
        }
    }
}
return output;

 

Produces this:

rbasgall_0-1659649772393.png

 

ChrisRoberts2
Occasional Contributor III

Thanks for this, its got me part way there 😊.  However I noticed that it changes the order of the fields, is there a way to display it as per the schema order?

0 Kudos
KenBuja
MVP Esteemed Contributor
XanderBakker
Esri Esteemed Contributor

Apart from the post mentioned by Ken, there are some comments that will be relevant for you:

0 Kudos
KevinMilton
New Contributor III

UPDATE!!

This is a confirmed bug, and the arcade script will not produce the results we are asking for. This bug is not repaired until the 10.7 license level.

0 Kudos
XanderBakker
Esri Esteemed Contributor

Can you share the number of the bug and the description?