Add a New Var w/o New Layer

1595
23
08-07-2020 04:01 PM
Lindsey_Whittington
New Contributor II

Very new to ArcGIS so sorry if this is a dumb question.

We are trying to add a new variable to a series of maps that have already been created, formatted, etc. I have tried doing this by merging the new variable using our unique key in "Append Data" but am unable to see the new variable in the var list when I do that. Any ideas? Using Arcade.

0 Kudos
23 Replies
Lindsey_Whittington
New Contributor II

Hey Xander Bakker‌!

The expression worked great for the first layer I added it to for the pop up configuration. When I went to put it into another layer, I got this error:

Execution Error:Cannot read property 'toString' of null

What does this mean? What would I need to adjust to get this to work in different layers where this property might occur?

Sorry for all the issues! Thanks for your help on this!

Lindsey

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi WhittingtonL_cohealthinst , 

Are you trying to do something similar on the female layer? If so, I can have a look. To answer your question. Apparently, somewhere along the road it has a variable containing the value null which is casted to string. I will have a look (assuming it is related to the female layer).

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi WhittingtonL_cohealthinst ,

Ok, I guess it is not related to the female layer, since it seems to be working with the same expression (just changed the text "Male" into "Female"):

0 Kudos
Lindsey_Whittington
New Contributor II

Hey Xander Bakker‌,

I currently have about 50 layers where I am trying to find a way to display all these years of data (probably should have said that earlier lol), so it might be the source data. I was using this on a layer that is looking at Substance Availability with tobacco and marijuana retailers. So, does this mean that there is missing data (null) or the expression is equal to null, which isn't identified what to output in the code? Are you thinking each of these code strings will need to be catered to the individual layers I am looking at? Or is there a way to get around this null issue if I get that error?

Seriously, thanks for your help on this!

Lindsey

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi Lindsey Whittington , 

There are always options to avoid the null error you are facing. If you can share the webmap with the layer I can have a look.

Are you planning to have all these layers in a single map (I strongly recommend you not to do that)? Maybe more importantly, for what audience are you preparing this and what are the expected workflows? If you have different requirements for different groups of people, it would be better to configure focused based apps for each group and not load too many layers into your map. You can also create a single pop-up combining information from multiple layers. It all depends on what will work best for the end user (and as long as it is possible to configure and performance is acceptable). 

0 Kudos
Lindsey_Whittington
New Contributor II

Hey Xander Bakker‌,

I have shared two more examples of the webmaps that I have made with the time aware data - I created different topic webmaps that all have their own corresponding application I created in the Webapp builder just to display the data using the time slider and the layer list widgets. I think there is about 13 applications, so the 50 layers are spread out throughout those based on topic. 

The audience is a health foundation who is using these applications to provide local data to different partners - so I would say the main audience would be the foundation and non-profits. I wanted to update the pop ups to have all the data so that users could get all the data they needed in one place instead of having to toggle through all years, click on their census tract or what have you, so that the user experience is a little easier. 

Definitely open to suggestions of the best way to handle this much data on all these applications - I have a knowledge of AGOL but not enough to create the right usability I need, I think. You have been such a great help on this!

Lindsey

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi WhittingtonL_cohealthinst ,

Not sure where you are getting this error. It seems to be working just fine:

// read out the location ID
var geoid = $feature["geoid_1"];
// create a query with that ID
var sql = "geoid_1 = @geoid";
// filter the data using the query
var fs = OrderBy(Filter($layer, sql), "State_Year ASC");

// get the count, and only process if you have results
var nodatayears = [];
var result = "Insurance rate through the years:";
var cnt = Count(fs);
if (cnt > 0) {
    // loop through results
    for (var f in fs) {
        var finalval = f["Value_Final"];
        if (finalval == -1) {
            // result += TextFormatting.NewLine + " - Data Not Available (" + f["State_Year"] + ")";            
            nodatayears[Count(nodatayears)] = f["State_Year"];
        } else {
            result += TextFormatting.NewLine + " - " + Round(f["Value_Final"], 1) + "% (" + f["State_Year"] + ")";
    }   }
}

if (Count(nodatayears) > 0) {
    result += TextFormatting.NewLine + " - Data Not Available for years: " + Concatenate(nodatayears, ", ");
}

return result;

... results in:

0 Kudos
Lindsey_Whittington
New Contributor II

Hey Xander Bakker,‌

I was having the error appear on the Substance Availability layer for alcohol retailers per 1,000 residents. Does it matter if there are layers that only have data for a single year? Would that create that error? It seems to be successful on layers with multiple years of data. What do you think?

Lindsey

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi Lindsey Whittington ,

It should also work when there is only 1 year available. In this case you have records for 2009, 2011, 2013, 2015 and 2017, but they have been marked as no data.

In this case it might be better to change the message, since you're not really presenting the data through the years (it is just a single year).

Lindsey_Whittington
New Contributor II

Hey Xander Bakker‌,

I have added the code to the Health Care map that I shared with you, and it worked perfect with all those years. When I went back and added the code to the Gender map, it worked fine for the Male layer, but gave me that same error for the Female layer (which you already showed above it worked fine when you did it). All I am doing is taking the code, copying and pasting it in one layer after another, and running it to test it. Is there something in this process that would cause this error to be displayed? I didn't have any issues with the Health Care layer, so I am confused why it is giving me troubles on random layers on other Webmaps, when it works fine on others and you didn't have any issues on your end. Suggestions? Things I can check on my end? Seems like a user error on my end for sure lol.

Sorry for all the belabored back and forth on this. I think I am almost there on this! You've been a great help!

Lindsey

0 Kudos