Hi,
in the Field Maps form, I'm trying to calculator a new ID value based on a selected grid and the MAX value (+1) in the layer. How can I apply the filter in the expression correctly?
Var GRID_ID_SELECT = AA
Var GridFilter = Filter($featureset, ‘GRID_ID = GRID_ID_SELECT')
Var NEW_ID = Max($feature.ID) + 1
return NEW_ID
Grid_ID | ID |
AA | 1 |
AA | 2 |
AA | 3 |
BB | 11 |
BB | 12 |
BB | 13 |
Thew NEW ID value should be 4.
(I'm new to Arcade and trying to figure this out, i have read some samples but didn't achieve my goal)
million thanks!!!
W
You have to get the max of the filtered featureset.
var GRID_ID_SELECT = AA
var GridFilter = Filter($featureset, "GRID_ID = @GRID_ID_SELECT")
var NEW_ID = Max(GridFilter, "ID") + 1
return NEW_ID
Thanks Johannes, for some reason it didn't work
I had simplified the code for this post....the actual codes are like this
For first 3 lines, i am able to get the value from other layer (point in polygon) - ie, GRID_ID
but adding 4,5,6 break the code:
1. var treeGrid = FeatureSetByName($map,"Grid")
2. var result = Intersects($feature, treeGrid)
3. var GRID_ID = Upper(first(result).MAP_ID)
4. var GridFilter = Filter($featureset, "MAP_CODE = @GRID_ID")
5. Var NEWID = Max(GridFilter, "SEQ") + 1
6. return NEWID
did i do something wrong? thanks!!!