Select to view content in your preferred language

Populate a List of Unique Identifiers Not Present in Layer

265
2
Jump to solution
10-17-2025 01:28 PM
Labels (1)
Bailey_Briggs
Emerging Contributor

I'm looking for a data expression/advanced formatting that will check if a survey123 'vehicle report' has been submitted by a user with a unique license plate based off a list of all license plates, an inventory list of ~200 or so records. The end goal would be if the license plate from the inventory does not have a matching report for that month, to list out the plate number so they can be contacted. 

The survey123 has a .csv choice list of all license plates, and that same .csv is used in the dashboard for fetching associated information on the vehicle, so the license plate field is identical and works with the filters. I'm looking for something similar to the reference toggle in an indicator, which works if I only needed a count of distinct plates compared to total plates, but not for listing out the plate number. 

Any help or advice is appreciated and am open to any suggestions! 

0 Kudos
1 Solution

Accepted Solutions
Neal_t_k
Frequent Contributor

@Bailey_Briggs   if you have both data sources in a map in your dashboard you may be able to do something similar in Advanced Formatting, not sure...but if you want to do a new data expression, using IndexOf  could work for you, basically it compares two lists and returns -1 if there is no match.

https://developers.arcgis.com/arcade/function-reference/array_functions/#indexof

something like this could be what you are after:

var portal = Portal('https://www.arcgis.com')

//feature to compare to
var layerA = FeatureSetByPortalItem(portal, '<layerID', LayerIndex, ['LicenseNum'])
//Feature with new licenses
var layerB = FeatureSetByPortalItem(portal, '<layerID', LayerIndex, ['LicenseNum'])//add any additional fields

var namesA = []
for (var a in layerA) {
    Push(namesA, a.LicenseNum)
}

var output = []
for (var b in layerB) {
    if (IndexOf(namesA, b.LicenseNum) == -1) {
        Push(output, {
            attributes: {
            LicenseNum: b.LicenseNum
			//add any additional fields
        }
        });
    }
}


return FeatureSet(Text({
    fields: [
        { name: "LicenseNum", type: "esriFieldTypeString"}
		//add any additional fields
    ],
    geometryType: "",
    features: output
}));

View solution in original post

2 Replies
Neal_t_k
Frequent Contributor

@Bailey_Briggs   if you have both data sources in a map in your dashboard you may be able to do something similar in Advanced Formatting, not sure...but if you want to do a new data expression, using IndexOf  could work for you, basically it compares two lists and returns -1 if there is no match.

https://developers.arcgis.com/arcade/function-reference/array_functions/#indexof

something like this could be what you are after:

var portal = Portal('https://www.arcgis.com')

//feature to compare to
var layerA = FeatureSetByPortalItem(portal, '<layerID', LayerIndex, ['LicenseNum'])
//Feature with new licenses
var layerB = FeatureSetByPortalItem(portal, '<layerID', LayerIndex, ['LicenseNum'])//add any additional fields

var namesA = []
for (var a in layerA) {
    Push(namesA, a.LicenseNum)
}

var output = []
for (var b in layerB) {
    if (IndexOf(namesA, b.LicenseNum) == -1) {
        Push(output, {
            attributes: {
            LicenseNum: b.LicenseNum
			//add any additional fields
        }
        });
    }
}


return FeatureSet(Text({
    fields: [
        { name: "LicenseNum", type: "esriFieldTypeString"}
		//add any additional fields
    ],
    geometryType: "",
    features: output
}));

Bailey_Briggs
Emerging Contributor

Thank you @Neal_t_k, here was my final expression for future reference:

var portal = Portal('https://www.arcgis.com')

// inventory
var layerA = FeatureSetByPortalItem(portal, 'redacted',0,['label'])
// monthly report
var layerB = FeatureSetByPortalItem(portal,'redacted',0,['license_plate'])

var namesA = []
for (var a in layerA) {
    Push(namesA, a.label)
}

var output = []
for (var b in layerB) {
    var plate = b.license_plate
    if (IndexOf(namesA, b.license_plate) == -1) {
        Push(output, {
          attributes: {
            "License_Plate_Number": plate
    }
        })
    }
}

var schema = {
  fields: [{ name: "License Plate Number", type: "esriFieldTypeString" }],
    geometryType: "",
    features: output
    }
return FeatureSet(Text(schema))
0 Kudos