Select to view content in your preferred language

related data Arcade expression in layer style

418
4
11-20-2024 03:49 AM
Labels (2)
HelenCooper
Frequent Contributor

Hi all, 

I've been using this incredibly helpful post (https://community.esri.com/t5/arcgis-online-blog/show-related-data-or-tables-in-pop-ups-with-arcade/...) to get my pop-up to show data from a related feature layer. 

My expression looks like this: 

//Access 'Facilities' table as a featureset
var portal = Portal("https://www.arcgis.com")
var facilities = FeatureSetByPortalItem(portal, "1e189022e7064e0e9b1bdaadef6d3b78")

//Filter related features by Site ID
var varSite = $feature.siteid
var filterStatement = 'siteid = @varSite'

//related features as a variable
var relatedData = Filter(facilities, filterStatement)

//Sort related features
var relatedDataSorted = Orderby(relatedData,'facilitytype ASC')

var popupString = ''
var facilityCount = 0

for (var f in relatedDataSorted){
  popupString += Text(f.facilitytype) + TextFormatting.NewLine
  facilityCount=facilityCount+1
}

return popupString

 

This works great within the pop-up, but I'm now trying to extend it to the style of the layer, so that I can vary the size of the point depending on the 'Count' (i.e. number of related features). 

At the moment the code doesn't work at all in the style expression builder - can anyone suggest where I'm going wrong?

Many thanks, 

Helen

4 Replies
RussRoberts
Esri Notable Contributor

Currently styling against related records is not supported at this time. It would be a pretty expensive operation to run the expression on each pan/zoom.

HelenCooper
Frequent Contributor

ok, thanks @RussRoberts!

0 Kudos
ChristopherCounsell
MVP Regular Contributor

As Russ said this isn't a great idea for dynamic symbolization. There's an idea for it somewhere.

But if you're just after count, you may be able to utilize a Join and count statistic. See this post here:

https://community.esri.com/t5/arcgis-online-questions/symbolize-by-related-table-in-arcgis-webmap/td...

There'll be some limitations listed below and you may have to remove the join to do things like add fields in future.

https://doc.arcgis.com/en/arcgis-online/analyze/join-features-mv.htm

 

HelenCooper
Frequent Contributor

Thanks @ChristopherCounsell , unfortunately I'm not hosting either of these layers, so my ability to set a join up is limited. 

0 Kudos