I have a table that is formed like this for example in a geodatabase:
Date | PreviousValue | CurrentValue |
22/10/2023 | 250 | 315 |
I'm creating an attribute rule whereby when a row is created in the table, the current value would then be automatically entered in the new previous value like so:
Date | PreviousValue | CurrentValue |
22/10/2023 | 250 | 315 |
23/10/2023 | 315 | 456 |
I have decided that I can order the date like so:
var ord = Top(OrderBy(fs, 'Date DESC'), 2);
To get the previous date, however I'm trying to return the value in that row. Is there an arcade expression for this? Any help appreciated.
Solved! Go to Solution.
So after talking to esri support they essentially nudged me in the absolute right direction so that I could have figured this out.
Essentially with their help and with my insatiable programming attitude that forces me to do things my way, I took the feature set and pushed the values into an array and worked on the array to give me the value I wanted like so:
var fs = FeatureSetByName($datastore, "Database.DBO.DatabaseTable");
var fs_arr = []
for(var f in fs) {
Push(fs_arr, f.CurrentValue)
}
//I don't want the currently entered value I want the previously entered
//value so I want the second to last entry in the array.
//Also, if the table only has one row we'll get an out of bounds error
if(Count(fs_arr) > 1){
Erase(fs_arr, -1);
var cg = Back(fs_arr);
return cg;
} else {
return 0;
}
So after talking to esri support they essentially nudged me in the absolute right direction so that I could have figured this out.
Essentially with their help and with my insatiable programming attitude that forces me to do things my way, I took the feature set and pushed the values into an array and worked on the array to give me the value I wanted like so:
var fs = FeatureSetByName($datastore, "Database.DBO.DatabaseTable");
var fs_arr = []
for(var f in fs) {
Push(fs_arr, f.CurrentValue)
}
//I don't want the currently entered value I want the previously entered
//value so I want the second to last entry in the array.
//Also, if the table only has one row we'll get an out of bounds error
if(Count(fs_arr) > 1){
Erase(fs_arr, -1);
var cg = Back(fs_arr);
return cg;
} else {
return 0;
}