I am trying to calculate a field in my table that is the sum of field GRID_COUNT in a feature class called 'HWA_GRIDS_TREATMENT_local', for all rows where the date of layer ''HWA_GRIDS_TREATMENT_local' matches the date in my table. The date fields are supposed to be date only but have time info, so I am trying to pull just the year, month and date in my filters.
Apologies for the unhelpful variable naming but hoping someone can understand. The expression is all valid but when I go to calculate it, the output is 0 (however there should be some values because there are features that meet this criteria).
Code:
var grid = FeatureSetByName($datastore,'HWA_GRIDS_TREATMENT_local',['MARK_X_DATE_ONLY','GRID_COUNT'],false);
var mcfc_grid = Filter(grid, "Team = 'MCFC'");
var filter_table = ISOYear($feature.Date_Only) + "-" + ISOMonth($feature.Date_Only) + "-" + Day($feature.Date_Only)
var mcfc_grid_dateonly = ISOYear("MARK_X_DATE_ONLY") + "-" + ISOMonth("MARK_X_DATE_ONLY") + "-" + Day("MARK_X_DATE_ONLY")
//var filter_expression_date = "TREAT_X_DATE_ONLY = filter_table"
var filtered_grid = filter(mcfc_grid,"@mcfc_grid_dateonly = @filter_table")
var trees =sum(filtered_grid, 'GRID_COUNT')
return trees
screenshot of the field calculator tool attached as well.