Using Distinct to create a List, cannot pan/zoom on map with actions

12-03-2021 12:44 PM
New Contributor II

Hi everyone,

I have a join layer view of water meter readings joined to parcels in which there could be several meter readings related to any given parcel. I want to create a List element of distinct parcels that have meter readings associated with it. I'm using a data expression to create my list element and so far I have the following in my expression:

var parcels = FeatureSetByPortalItem(Portal('myurlhere'), 'myItemIDhere', 0, ['*'], true)

var parcelsMeterReadings = Filter(parcels, 'ADDRESS IS NOT NULL')

var uniqueParcelsWithMeters = Distinct(parcelsMeterReadings, ['ADDRESS', 'GlobalID'])

return uniqueParcelsWithMeters


This successfully returns the information I want to display in my list, however I can't use the pan/zoom actions to zoom the map to a selected parcel. I am able to use the pan/zoom actions when I return variable "parcels" and when I return variable "parcelsMeterReadings" (ie, with my original FeatureSet and with a filtered FeatureSet), but once I use the Distinct function, I lose the geometry. Is there any way around this?

0 Kudos
1 Reply
MVP Esteemed Contributor

Your Distinct function is including the GlobalID in the fields parameter, which is essentially just returning the same as the input FeatureSet, since, by definition, every feature will have it's own distinct GlobalID value.

In order to drop multiple readings for a single address, but still return individual features with geometry, you'll need to define some method of actually picking out which reading to take when there are more than one.

Distinct drops the geometry because it's purpose is simply to identify distinct values out of a list of potential duplicates, not return individual features with geometry. If you need geometry, then it's not really the function you want. You could, however, use the values returned from Distinct and create a new FeatureSet.

Try something like

var uniqueParcelsWithMeters = Distinct(parcelsMeterReadings, ['ADDRESS'])

instead. That will truly return the distinct parcels by address, and you can use those to populate a new FeatureSet. You might want to look at the example expressions for more advanced examples to help with this.

- Josh Carlson
Kendall County GIS
0 Kudos