Filter table records and related feature class records

814
7
04-26-2022 10:31 AM
SDeGrootNPS
New Contributor II

I am sure someone has encountered this before, but I cannot find any guidance about it.

I have a point feature class with the locations of assets and a linked table for inspections. The table has no location information, only the feature class has locations.

Assets noted to be in poor condition during inspection, I want to see on a map.

It is easy to apply a filter to the inspection table for poor condition, but on the map all assets still show. How do I get the feature class records showing on the map to match the filtered table records?

For example, when I apply a filter to the table, there are 45 records meeting that condition. However, there are 2700 records showing on the map (all asset records). What I want to see on the map are just the 45 assets meeting the table's filter condition.

Ideas or links to posts or documentation addressing this are appreciated.

0 Kudos
7 Replies
3raan
by
New Contributor III

I hope the following article helps: https://doc.arcgis.com/en/arcgis-online/reference/apply-filters.htm

Essentially, when you are in the web viewer for the feature class, selected the filter button. When the filter windows pops up, input a display expression.

ex. "Condition" + "Is" + "poor condition"

0 Kudos
SDeGrootNPS
New Contributor II

Thanks, @3raan,

The article is how to apply a filter to a stand-alone feature class.

I need to apply a filter to a related table, and have the feature class results filtered also.

I cannot apply the filter to the feature class because it does not contain the asset condition fields. They are in the related table.

I can apply the filter to the table, but cannot view the results on a map because the table contains no location data.

 

0 Kudos
ZoeBroek
Occasional Contributor

Yes this must be possible! If you figure it out please let me know. 

I think the solution is an Arcade expression which uses the Data function FeatureSetByRelationshipName to return a specific feature in the related table. Something like: 

var id = $feature.XXID;
var sql = "XXID = " + xxid ;  // insert your matching "join" like attribute here for feature and related feature
var inspectietabel = FeatureSetByName($map,"Inspectie")
var inspecties = Filter(inspectiontabel, sql);
for (var inspectie in inspecties)
{
var inspconditie = inspectie.condition;
}
return inspconditie

And to this Arcade you should add an IIF function to return specific colors or value because unfortunately in an styling expression you can't use FeatureSetByRelationshipName: 

Iif(inspconditie== "low", "#FFFFF", 

And then configure your styling in the map to that attribute created by the expression. If needed set the remaining features to invisable. 

If anyone has a better idea please let me know!

- Zoë

0 Kudos
ZoeBroek
Occasional Contributor

Visualizing related data with Join Features in ArcGIS Online (esri.com)

Or do this. Join your latest related table features to your Feature Layer and then filter condition. 

0 Kudos
ArmstKP
Occasional Contributor III

Joining will cause you too lose your attachments, if you have any!!!

0 Kudos
SDeGrootNPS
New Contributor II

Thanks, @ZoeBroek !

That worked. I joined the feature class with asset locations to the inspection table via the globalid and parentglobalid fields. This created a new feature class with all the fields, and I can create filters on this new feature class or filtered view layers from it, that display on a map only assets meeting a particular inspection condition.

Still not sure if the join will update as I add assets to the inventory-- ideally, it would update.

0 Kudos
ZoeBroek
Occasional Contributor

You're welcome! The data does update with your new assets, because the join created a view of the hosted feature layers you joined. 

0 Kudos