Select to view content in your preferred language

Attribute Rule to auto-populate a field based on another field in the same feature class

155
1
2 weeks ago
SuzyFer
New Contributor II

Hello,

I am attempting to auto-populate a field with a calculation (?) attribute rule, based on another field in the same feature class, could someone help me figure this out please? Being fairly new to arcade.

I have 4 different fields containing habitat information and a main habitat field, for example:
level 1, level 2, level 3, level 4, & habitat.

Not all levels will be populated necessarily, so I would like the habitat field to auto-populate with the value based on which one of these levels is populated. So for example, if level 4 is empty - I want to check if level 3 has a value. If so, auto-populate with that. If level 3 is empty, check level 2 for a value and use that, but again if empty, use the value from level 1. 

Thanks!

Tags (2)
0 Kudos
1 Reply
Jake_S
by Esri Contributor
Esri Contributor

Hey @SuzyFer !

There are other ways you can do this but this is the most simplistic.

 

var level4 = $feature.level4;
var level3 = $feature.level3;
var level2 = $feature.level2;
var level1 = $feature.level1;

var result;

if (!IsEmpty(level4)) {
  result = level4;
} else if (!IsEmpty(level3)) {
  result = level3;
} else if (!IsEmpty(level2)) {
  result = level2;
} else if (!IsEmpty(level1)) {
  result = level1;
}

return result;

 

Hope this helps.

~Jake

0 Kudos