Select to view content in your preferred language

Arcade: Intersect feature layers and summarise related table fields

2797
11
05-07-2020 09:43 PM
CPoynter
Occasional Contributor III

Hi,

I have looked at several Arcade related postings and trying to string together some code to perform the following operation:

1) Intersect a point feature layer with related table with regional polygon feature layer (LLS Layer is where the Arcade expression is being displayed in pop-up):

This portion works ok, but I may need to know the count of 'species sampled'. f.species is within the feature layer.

2) I wish to summarise records in the point feature layer related table:

   End result is pop-up will show:

  • region name [from feature layer]
  • f.species and count [from feature layer]
  • microbe name and the count of microbe (eg. above would be 'Pasteruella aerogenes: 4 samples') [related table]
  • Each test item and count (eg. 'Amikacin - Intermediate (3 samples)) [related table]
  • I will also need a decision tree if I have cases where I have a number of mixed samples intermediate/sensitive/resistant) [related table]

I am thinking I will need one common expression tailored for:

  • each microbe or
  • each microbe and each test item or
  • combinations or each

Advice greatly appreciated.

0 Kudos
11 Replies
XanderBakker
Esri Esteemed Contributor

Hi Craig Poynter ,

Creating a html table with an Arcade expression is only possible in ArcGIS Pro at the moment. So, yes it would be possible, but only in ArcGIS Pro. In ArcGIS Online, any html returned is not parsed as html but as plain text. To create a html styles table with content from the related table would requiere an arcade expression for each cell of the table and some additional one to hide rows if there is not content. This would take hundreds of Arcade expressions, and forever to return the result to the user. 

For now, if this 10-15 seconds of processing time is acceptable for your end users (personally, I don't think it will be) you could include the other information as plain text in the pop-up. You need to take into account that when information starts to grow, processing time will further increase. 

0 Kudos
Czapiga_Jason
New Contributor II

Thank you so much!  I've been trying to figure this out for weeks.  I had a similar workflow, but my code only returned one record from the related table.  I used the example you posted above and it worked great!  Here's mine that DID NOT work as an example for others that might be taking this path...use Xander's solution above!

var complaintPts = FeatureSetByName($map,"ComplaintPoints",['*'],true)
var townComplaints = Intersects($feature, complaintPts)
var tbl = FeatureSetByName($map,"IncidentRepeat",['*'],true);
var FeatureID =''
for (var f in townComplaints)
{
FeatureID = f.globalid
var sql = "parentglobalid = '" + FeatureID + "'"
var complaints = Filter(tbl,sql)
var x = GroupBy(complaints,'Species',
{name: 'SpCount', expression: '1', statistic: 'COUNT'})

var popup=""
for (var row in x){
popup += row.Species +": "+row.SpCount + TextFormatting.NewLine
}
}
return popup

0 Kudos