I am trying to populate a field 'MARK_X_DATE' with a date value from another layer in field calculator on ArcGIS Pro. However, I only want it to pull the date if both GRID_ID and PROJECT/MARKED_YEAR are the same. MARK_X_DATE is a date only field, and DATE_TIME is a date field (has both date and time).
There are many instances where these filters should be met, but I keep getting a null output. I should note too I've used this in another context in agol, and while I was not pulling a date field I was summing a long field, it worked. So I wonder if something to do with the dates is off. Any thoughts very much appreciated!
var P = Portal('https://www.arcgis.com');
var tree = FeatureSetByPortalItem(P,'20d935a4b9e740eea4b931ddfc91887b',0,['DATE_TIME','PROJECT','GRID_ID'],False)
var filter_by_grid = "'" + $feature["GRID_ID"] + "'"
var filter_by_year = "'" + $feature["MARKED_YEAR"] + "'"
// the filter expression
var filter_expression_grid = "GRID_ID = " + filter_by_grid
var filter_expression_year = "PROJECT = " + filter_by_year
// filter the plots to only this block
var filtered_grid = filter(tree, filter_expression_grid)
var filtered_year = filter(filtered_grid, filter_expression_year)
// get the count of plots
var date = DateOnly(filtered_year, 'DATE_TIME')
return date
Are you sure the issue is date related? If you remove the date-related queries do the other queries work as expected? If the GRID_ID query is not working correctly for some reason, then it won't matter whether the MARKED_YEAR query is working or not.
Yeah I tried it with just the GRID_ID filter and still not getting any output
Beyond the filters, you are not correctly using the ArcGIS Arcade DateOnly function. You are passing the function a feature set and column name, which it has no idea what to do with, so that could be why null is getting returned.