Select to view content in your preferred language

Arcade expression to populate field based on values in multiple other fields

1724
10
Jump to solution
11-06-2024 11:54 PM
Labels (2)
AndrewHankinson
Regular Contributor

Hi, 

I have an arcade expression which populates a field base on all the variables of 3 other fields, I have written this in a very long winded way but it works. 

Currently the example is like this.

if($feature.Feat_1 == 'A' && $feature.Feat_2 == 'A' && $feature.3 == 'A')
{return 'Y'}

if($feature.Feat_1 == 'A' && $feature.Feat_2 == 'A' && $feature.3 == 'B')
{return 'Y'}

This repeats with every single possible variation . . . . . 

else {return 'Unknown'}

I was thinking that creating a variable for each of the fields would work but I'm not getting anywhere with my limited knowledge of arcade and after some further reading over similar needs on the forum I'm unsure of if I should be using a When or Expects function??

Any help would be greatly appreciated. 

0 Kudos
10 Replies
KenBuja
MVP Esteemed Contributor

You could also consolidate your arrays with something like this, but you might prefer the more verbose method, which is easier to understand.

var width1 = ["3m4m","4m"];
var width2 = ["1m","1m2m", "2m3m"];
var width3 = ["2m3m"];
var depth1 = ["1m","1m2m", "2m3m","3m4m","4m"];
var depth2 = ["2m3m", "3m4m","4m"];
var basesub1 = ["BDP","VDP"];
var basesub2 = ["BM","VM","VSP","VSM","VSP"];
var basesub3 = ["VSM","VM","BM"];
var basesub4 = ["VSP","PSS","PSD"];
0 Kudos