Select to view content in your preferred language

One Pop Up Expression for Multiple Attributes?

2112
5
Jump to solution
05-10-2019 12:24 PM
by Anonymous User
Not applicable

Is there a way to create one Arcade expression that could be applied across multiple attributes instead of creating an expression for each one?

Example:

I have a feature layer and it has, let's say, 20 attributes. If there is a NULL I want the pop up to display "No observations", and if there is data, display said data. Right now I currently have to make an Arcade expression for each attribute. Here is my expression;

Text(IIf(IsEmpty($feature.Est1), "No observations", $feature.Est1), '#,###')

Now instead of copying and pasting this expression 20 times and just changing what attribute it applies to is there a way to just do it with one? This also applies to Pro as well (Better Pop Up Arcade Expression?).

Any easier way to do it would be to change the data in Pro and have be text but then that throws a bunch of stuff off and that's a whole different topic. Thanks everyone!

0 Kudos
1 Solution

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

Any HTML you generate in the expression will not be honored in the pop-up window.

An example of looping through multiple attributes:

var atts = [["Feature code", $feature.FEATURECODE],
           ["Floor count", $feature.FLOORCOUNT],
           ["Roof form", $feature.ROOFFORM],
           ["Roof direction", $feature.ROOFDIR]];
Console(atts);

var result = "";           
for (var i in atts) {
    Console(i);
    var att = atts[i];
    Console(att);
    if (IsEmpty(att[1])) {
        if (result  == "") {
            result = att[0] + ": " + "No information available";
        } else {
            result += TextFormatting.NewLine + att[0] + ": " + "No information available";
        }
    } else {
        if (result  == "") {
            result = att[0] + ": " + att[1];
        } else {
            result += TextFormatting.NewLine + att[0] + ": " + att[1];
        }
    }
}

return result;

View solution in original post

5 Replies
XanderBakker
Esri Esteemed Contributor

There are two ways you can do this:

  • You can create a single Arcade expression that goes through the 20 attributes and validates Null values and changes this for No observations and alters the formatting of numeric values. No problem there. However, formatting the result will be very limited. It will all use the same color, font and size.
  • You can also choose to create 20 expressions, which will be more work, but than you will have control over how to format the result using different colors and other font settings.

You cannot create a single expression that takes a parameter so that a single expression can be used 20 times to create 20 different outputs. 

0 Kudos
by Anonymous User
Not applicable

How would I build an Arcade expression to iterate through the attributes? I am a little bit familiar with ArcPy (loops and Data Access Cursors) but not familiar with how to do this with Arcade. Also, with one expression it could be possible to build a custom pop-up table with HTML I would think.

0 Kudos
XanderBakker
Esri Esteemed Contributor

Any HTML you generate in the expression will not be honored in the pop-up window.

An example of looping through multiple attributes:

var atts = [["Feature code", $feature.FEATURECODE],
           ["Floor count", $feature.FLOORCOUNT],
           ["Roof form", $feature.ROOFFORM],
           ["Roof direction", $feature.ROOFDIR]];
Console(atts);

var result = "";           
for (var i in atts) {
    Console(i);
    var att = atts[i];
    Console(att);
    if (IsEmpty(att[1])) {
        if (result  == "") {
            result = att[0] + ": " + "No information available";
        } else {
            result += TextFormatting.NewLine + att[0] + ": " + "No information available";
        }
    } else {
        if (result  == "") {
            result = att[0] + ": " + att[1];
        } else {
            result += TextFormatting.NewLine + att[0] + ": " + att[1];
        }
    }
}

return result;
by Anonymous User
Not applicable

Sorry, I think I misspoke about the HTML portion. How I do it now is a build a bunch of Arcade expressions and then when I go to configure my pop-ups I select custom attribute display. In there I'll create my own display using HTML, not using HTML in the Arcade expression.

0 Kudos
by Anonymous User
Not applicable

Actually, disregard my last comment. I'm testing out the expression you provided and now I understand what you are talking about. I think I can make this work. Thank you for your help!

0 Kudos