Arcade Expression not returning all results in AGOL

1166
4
Jump to solution
08-22-2018 08:26 AM
KristinDitterline
New Contributor II

I have set up an Arcade expression that queries two fields and returns the results to symbolize on. Using the expression in ArcGIS Pro brings back all the expected results, using the same expression in AGOL does not bring back all the results. Any advice would be helpful at this point.

Arcade expression is very simple:

if($feature.speed == 0 && $feature.messageType == "IGNITION OFF")
{return "Position - Not Moving";}
else if ($feature.speed < 1 && $feature.messageType == "Position")
{return "Stopped Position";}
else if ($feature.messageType == "POWER DISCONNECT")
{return "Stopped Power Disconnect";}
else if ($feature.messageType == "Position")
{return "Position-Moving";}
else if ($feature.messageType == "IGNITION ON")
{return "Ignition On";}
else if ($feature.messageType == "IGNITION OFF")
{return "Ignition Off";}
else if ($feature.messageType == "SPEEDING")
{return "Speeding";}
else if ($feature.messageType == "IDLE")
{return "Excessive Idle/Long Stop (5 minutes)";}
else if ($feature.messageType == "IDLE END w Duration")
{return "Idle w Duration";}
else if ($feature.messageType == "HARSH ACCELERATION")
{return "Harsh Acceleration";}
else if ($feature.messageType == "HARSH BRAKING")
{return "Harsh Braking";}
else if ($feature.messageType == "POSSIBLE ACCIDENT")
{return "Impact Possible Accident";}
else if ($feature.messageType == "POWER CONNECT")
{return "External Power";}
else if ($feature.messageType == "POWER DISCONNECT")
{return "Internal Power";}
else if ($feature.messageType == "LEFT TURN")
{return "Harsh Left";}
else if ($feature.messageType == "RIGHT TURN")
{return "Harsh Right";}
else
{return "Other";}

#symbols with arcade

0 Kudos
1 Solution

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

I have seen this behavior before. This may be related to the fact that ArcGIS Online does not scan all the possibilities or all the data (how many features do you have?). You could hack the json of the webmap in AGO assistant as explained in this thread: Creating a legend with Arcade with data populated later  and add the missing value to the legend. 

I still strongly believe that we would benefit strongly from being able to manually add multiple values to the legend to be able to symbolize each one. Would be great to see an idea for that!

CC Kelly Gerrow

View solution in original post

4 Replies
KristianEkenes
Esri Regular Contributor

Could you share the webmap? It could be because AGOL only symbolizes the first 10 values. All others are lumped into the "Other" category. You should still be able to see them listed when you open up the style options. There you can drag them out and give them proper symbols.

Also, on a minor note, you can also take advantage of the When() function in Arcade to achieve the same result. I find it a little more readable, but it's totally up to whether or not you find it useful:

When(
  $feature.speed == 0 && $feature.messageType == "IGNITION OFF", "Position - Not Moving",
  $feature.speed < 1 && $feature.messageType == "Position", "Stopped Position",
  $feature.messageType == "POWER DISCONNECT", "Stopped Power Disconnect",
  $feature.messageType == "Position", "Position-Moving",
  $feature.messageType == "IGNITION ON", "Ignition On",
  $feature.messageType == "IGNITION OFF", "Ignition Off",
  $feature.messageType == "SPEEDING", "Speeding",
  $feature.messageType == "IDLE", "Excessive Idle/Long Stop (5 minutes)",
  $feature.messageType == "IDLE END w Duration", "Idle w Duration",
  $feature.messageType == "HARSH ACCELERATION", "Harsh Acceleration",
  $feature.messageType == "HARSH BRAKING", "Harsh Braking",
  $feature.messageType == "POSSIBLE ACCIDENT", "Impact Possible Accident",
  $feature.messageType == "POWER CONNECT", "External Power",
  $feature.messageType == "POWER DISCONNECT", "Internal Power",
  $feature.messageType == "LEFT TURN", "Harsh Left",
  $feature.messageType == "RIGHT TURN", "Harsh Right",
"Other")
KristinDitterline
New Contributor II

Thank you for the "when" option, still super new to Arcade (and any programming language) so any tips are useful! Unfortunately, I can't share the map out because it contains client data that can't be openly shared. 

I have 'ungrouped' symbols before in AGOL, but that's not happening in this case, it's not even hitting the 10 symbol limit in AGOL, so I'm at a bit of a loss. Thanks for the help!

0 Kudos
XanderBakker
Esri Esteemed Contributor

I have seen this behavior before. This may be related to the fact that ArcGIS Online does not scan all the possibilities or all the data (how many features do you have?). You could hack the json of the webmap in AGO assistant as explained in this thread: Creating a legend with Arcade with data populated later  and add the missing value to the legend. 

I still strongly believe that we would benefit strongly from being able to manually add multiple values to the legend to be able to symbolize each one. Would be great to see an idea for that!

CC Kelly Gerrow

KristinDitterline
New Contributor II

Thanks for the suggestion, Xander, forgot to respond all those months ago. This workaround has served me well!