Hello all,
I am trying to flag any rows that contain a value greater than a column value from a different table. Based on the code below, I am having an issue referring to the MLENGTH field. It says a Dictionary Type is expected.
var lrsRoute = FeatureSetByName($datastore, 'RH_LRS_Routes', ['ROUTEID', 'MLENGTH'], false)
var routeID = $feature.ROUTEID
var beg_mi = $feature.BEG_MI
var end_mi = $feature.END_MI
var maxMileage = Max([beg_mi, end_mi])
var routeFilter = Filter(lrsRoute, "ROUTEID = @routeID")
IIF(maxMileage < routeFilter.MLENGTH, True, False)
Filter returns a FeatureSet and you need the first feature in that set for your IFF function.
var routeFilter = First(Filter(lrsRoute, "ROUTEID = @routeID"));
Not sure if I 100% understand what you are trying to achieve (the filter function does not make sense to me) - I assume your end goal is to have either the value True or False written to your feature's attribute table. If so, I think your expression needs to look something more like this:
var lrsRoute = FeatureSetByName($datastore, 'RH_LRS_Routes', ['ROUTEID', 'MLENGTH'], false);
var maxMileage=Max($feature.BEG_MI ,$feature.END_MI);
var routeFilter = Filter(lrsRoute, "ROUTEID = @routeID");
for (var Route in routeFilter){
If (maxMileage < $feature.MLENGHT){
return ‘True’}
Else {
Return ‘False’}}
So the lrsRoute table is a live table that gets updated frequently. It has a RouteID field and the Mlength value that I am trying to check against.
The $feature table that is grabbing BEG_MI and END_MI and ROUTEID is what I am actually trying to check. If the maxMileage is greater than the Mlength field from the lrsRoute table, flag it as an error.
var lrsRoute = FeatureSetByName($datastore, 'RH_LRS_Routes', ['ROUTEID', 'MLENGTH'], false);
for (var row in lrsRoute){
var id = row.ROUTEID
var filteredRow = Filter($feature, “routeID = @id”)
for (var feat in FilteredRow){
var maxMileage=Max(feat.BEG_MI ,feat.END_MI);
If (maxMileage < feat.MLENGHT){
return “True”}
else{
return “False”}
}}