Select to view content in your preferred language

Help with FeatureSetByPortal function to compare 2 layers - return info from 1 layer not in another

203
0
11-02-2024 06:09 PM
Labels (1)
LS-SD
by
Emerging Contributor

Need a little help getting my expression to work for dashboard list. 

I am trying to compare 2 layers - 1 has all locations and 1 enroute locations.  I want my list to display locations from all locations layer that are NOT in enroute locations layer.  Am I on the right track?  I had to comment out the line with Unique since that function isn't available. In theory, I shouldn't need but if user sends a duplicate survey in, there might be duplicates. I would want to evaluate the earliest timestamp.  Also, the enroute_date is stored as a date/time. I only care about comparing the date.  Would this be correct instead:

var today = new Date();  
var dateString = today.toISOString().split('T')[0];  // will this work to get date only?  if so, how to compare to the date in enroute_date? 

var today = Date(); // Get current date as a string - includes timestamp

// Define the portal
var portal = Portal('https://gis-portal.xyz.gov/arcgis');

// Access the Vote_Center_Status layer- try vcloc instead of location_id
var voteCenters = featureSetByPortalItem(portal, '62f125f3eeb441afbf197128740d6fc6', 0, ['enroute_date', 'vcloc'], false);

// Access the VC_All layer- try loc_id, vc_site instead of location_id
var allVoteCenters = featureSetByPortalItem(portal, '7ca0a09aac254fe88467bb59b5d7a184', 0, ['loc_id', 'vc_site'], false);

// Filter Vote_Center_Status for locations that are enroute today
var enrouteCenters = Filter(voteCenters, 'enroute_date = @today');

// Extract IDs or locations from the filtered vote center status
var enrouteIDs = Unique(enrouteCenters, 'vcloc');

// Filter vc_all to get locations that are NOT en route – try loc_id instead of location_id
var notEnroute = Filter(allVoteCenters, 'NOT(loc_id IN @enrouteCenters)');

// Return the result
return notEnroute;

Testing returns this: 

LSSD_0-1730595356608.png

When I save and go back a screen, I see the error that it's unable to execute Arcade script:

LSSD_1-1730595392751.png

I want to be able to display the {vc_site} and {loc_id} that is returned. 

Thank you in advance for any help on this. Need to get working asap (of course).

 

0 Kudos
0 Replies