Select to view content in your preferred language

Arcade: Return value from a specific date in table

498
1
Jump to solution
10-23-2023 04:12 PM
Labels (3)
KristinVernon1
New Contributor III

I have a table that is formed like this for example in a geodatabase:

DatePreviousValueCurrentValue
22/10/2023250315

 

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:

DatePreviousValueCurrentValue
22/10/2023250315
23/10/2023315456

 

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.

0 Kudos
1 Solution

Accepted Solutions
KristinVernon1
New Contributor III

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;
}

View solution in original post

0 Kudos
1 Reply
KristinVernon1
New Contributor III

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;
}
0 Kudos