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!
Solved! Go to Solution.
@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
}));s
@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
}));s
Thank you @Neal_t_k, here was my final expression for future reference: