<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Arcade expression to populate field based on values in multiple other fields in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-to-populate-field-based-on/m-p/1556200#M89874</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Currently the example is like this.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;if($feature.Feat_1 == 'A' &amp;amp;&amp;amp; $feature.Feat_2 == 'A' &amp;amp;&amp;amp; $feature.3 == 'A')&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{return 'Y'}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if($feature.Feat_1 == 'A' &amp;amp;&amp;amp; $feature.Feat_2 == 'A' &amp;amp;&amp;amp; $feature.3 == 'B')&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{return 'Y'}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;This repeats with every single possible variation . . . . .&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;else {return 'Unknown'}&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;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??&lt;BR /&gt;&lt;BR /&gt;Any help would be greatly appreciated.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 07 Nov 2024 07:54:44 GMT</pubDate>
    <dc:creator>AndrewHankinson</dc:creator>
    <dc:date>2024-11-07T07:54:44Z</dc:date>
    <item>
      <title>Arcade expression to populate field based on values in multiple other fields</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-to-populate-field-based-on/m-p/1556200#M89874</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Currently the example is like this.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;if($feature.Feat_1 == 'A' &amp;amp;&amp;amp; $feature.Feat_2 == 'A' &amp;amp;&amp;amp; $feature.3 == 'A')&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{return 'Y'}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if($feature.Feat_1 == 'A' &amp;amp;&amp;amp; $feature.Feat_2 == 'A' &amp;amp;&amp;amp; $feature.3 == 'B')&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;{return 'Y'}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;This repeats with every single possible variation . . . . .&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;else {return 'Unknown'}&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;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??&lt;BR /&gt;&lt;BR /&gt;Any help would be greatly appreciated.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 07:54:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-to-populate-field-based-on/m-p/1556200#M89874</guid>
      <dc:creator>AndrewHankinson</dc:creator>
      <dc:date>2024-11-07T07:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to populate field based on values in multiple other fields</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-to-populate-field-based-on/m-p/1556267#M89876</link>
      <description>&lt;P&gt;What are the possible values of the three fields? Could you go into more detail about what types of returns you'd expect besides "Y" and "Unknown"?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 14:08:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-to-populate-field-based-on/m-p/1556267#M89876</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-11-07T14:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to populate field based on values in multiple other fields</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-to-populate-field-based-on/m-p/1556309#M89879</link>
      <description>&lt;P&gt;It's hard to give a better answer without knowing the data, but there are different ways to do what you're doing.&amp;nbsp; Here is one using When():&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var feat1 = $feature.Feat_1
var feat2 = $feature.Feat_2
var feat3 = $feature.Feat_3

var featlist = feat1 + feat2 + feat3

return When(featlist == 'AAA', 'Y',
featlist == 'AAB', 'Y',
featlist == 'ABA', 'N',
.......,
'defaultvalue')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Nov 2024 15:18:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-to-populate-field-based-on/m-p/1556309#M89879</guid>
      <dc:creator>dgiersz_cuyahoga</dc:creator>
      <dc:date>2024-11-07T15:18:20Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to populate field based on values in multiple other fields</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-to-populate-field-based-on/m-p/1556664#M89928</link>
      <description>&lt;P&gt;Morning,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry, there in this current example there are 3 fields each of which have multiple possible data entries.&lt;BR /&gt;&lt;BR /&gt;Field 1 - Width - 1m, 1m2, 2m3m, 3m4m, 4m&lt;/P&gt;&lt;P&gt;Field 2 - Depth - 1m, 1m2, 2m3m, 3m4m, 4m&lt;BR /&gt;&lt;BR /&gt;Field 3 - Side angle - St, M, Sv, V&lt;BR /&gt;&lt;BR /&gt;The returns I'm looking for would ideally be anything that is 1m wide or 4m deep or has a side angle of St or M would be 'N'.&lt;BR /&gt;&lt;BR /&gt;Then any combination of the above would be 'Y' else 'Unknown'.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2024 00:24:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-to-populate-field-based-on/m-p/1556664#M89928</guid>
      <dc:creator>AndrewHankinson</dc:creator>
      <dc:date>2024-11-08T00:24:35Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to populate field based on values in multiple other fields</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-to-populate-field-based-on/m-p/1556666#M89929</link>
      <description>&lt;P&gt;Thanks for the reply, I was wondering what you use to get the screenshot of the expression? I use notebooks in ArcPro, the field calculator or Notepad++ but none of these look like your screenshot.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Nov 2024 00:28:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-to-populate-field-based-on/m-p/1556666#M89929</guid>
      <dc:creator>AndrewHankinson</dc:creator>
      <dc:date>2024-11-08T00:28:41Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to populate field based on values in multiple other fields</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-to-populate-field-based-on/m-p/1556824#M89950</link>
      <description>&lt;P&gt;If I understand your logic correctly, this should work&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var sizes = ["1m", "1m2", "2m3m", "3m4m", "4m"];
var angles = ["Sv", "V"];

When ($feature.Feat_width == "1m" || $feature.Feat_depth == "4m" || IndexOf(["St", "M"], $feature.Slope_degrees) &amp;gt; -1, "N",
      IndexOf(sizes, $feature.Feat_width) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(sizes, $feature.Feat_depth) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(angles, $feature.Slope_degrees) &amp;gt; -1, "Y",
     "Unknown");&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 08 Nov 2024 15:43:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-to-populate-field-based-on/m-p/1556824#M89950</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-11-08T15:43:41Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to populate field based on values in multiple other fields</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-to-populate-field-based-on/m-p/1557387#M90009</link>
      <description>&lt;P&gt;Amazing, that's great thank you, just need an "m" for the "1m2m" option and it worked great!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2024 04:09:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-to-populate-field-based-on/m-p/1557387#M90009</guid>
      <dc:creator>AndrewHankinson</dc:creator>
      <dc:date>2024-11-12T04:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to populate field based on values in multiple other fields</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-to-populate-field-based-on/m-p/1557391#M90010</link>
      <description>&lt;P&gt;Hi again,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought I'd take your example and try to apply it to another field, which has more variables and more outcomes.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;What I have done is clearly wrong and probably oversimplified and so doesn't do what I'd like. It works, as in there are no errors but I only get one output, which is correct, and all the other values are 'Unknown'. As opposed to all fields being populated based on the variables.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I've attached the expression. Would you be able to advise?&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2024 05:35:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-to-populate-field-based-on/m-p/1557391#M90010</guid>
      <dc:creator>AndrewHankinson</dc:creator>
      <dc:date>2024-11-12T05:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to populate field based on values in multiple other fields</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-to-populate-field-based-on/m-p/1557531#M90039</link>
      <description>&lt;P&gt;That's not a screenshot. When you post there is an 'Expand toolbar' option (the 3 dots at the end).&lt;/P&gt;&lt;P&gt;From here you can insert code formatting using the '&amp;lt;/&amp;gt;' button.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2024 15:04:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-to-populate-field-based-on/m-p/1557531#M90039</guid>
      <dc:creator>dgiersz_cuyahoga</dc:creator>
      <dc:date>2024-11-12T15:04:40Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to populate field based on values in multiple other fields</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-to-populate-field-based-on/m-p/1557556#M90043</link>
      <description>&lt;P&gt;When posting code, please use the "&lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633#U1007633" target="_self"&gt;Insert/Edit code sample&lt;/A&gt;" button instead of attaching it as a text file. It makes reviewing the code easier.&lt;/P&gt;&lt;P&gt;You're using the When function with an &lt;A href="https://developers.arcgis.com/arcade/guide/return/#implicit-returns" target="_self"&gt;implicit return&lt;/A&gt;, meaning it will return just the last executable statement. You'll have to combine them into one When function&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var PBwidth = ["3m4m","4m"];
var PBdepth = ["1m","1m2m", "2m3m","3m4m","4m"];
var PBbasesub = ["BDP","VDP"];
var SBwidth = ["3m4m","4m"];
var SBdepth = ["1m","1m2m", "2m3m", "3m4m","4m"];
var SBbasesub = ["BM","VM","VSP","VSM","VSP"];
var PDwidth = ["1m","1m2m", "2m3m"];
var PDdepth = ["1m","1m2m", "2m3m", "3m4m","4m"];
var PDbasesub = ["BDP","VDP"];
var TDwidth = ["2m3m"];
var TDdepth = ["2m3m", "3m4m","4m"];
var TDbasesub = ["BDP","VDP"];
var TDflowpres = ["FP"];
var SDwidth = ["1m","1m2m", "2m3m"];
var SDdepth = ["1m","1m2m", "2m3m", "3m4m","4m"];
var SDbasesub = ["VSM","VM","BM"];
var MDwidth = ["1m","1m2m", "2m3m"];
var MDdepth = ["1m","1m2m", "2m3m", "3m4m","4m"];
var MDbasesub = ["VSP","PSS","PSD"];

When (IndexOf(PBwidth, $feature.Feat_width) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(PBdepth, $feature.Feat_depth) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(PBbasesub, $feature.Base_sub) &amp;gt; -1, "PB",
      IndexOf(SBwidth, $feature.Feat_width) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(SBdepth, $feature.Feat_depth) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(SBbasesub, $feature.Base_sub) &amp;gt; -1, "SB", 
      IndexOf(PDwidth, $feature.Feat_width) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(PDdepth, $feature.Feat_depth) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(PDbasesub, $feature.Base_sub) &amp;gt; -1, "PD",
      IndexOf(TDwidth, $feature.Feat_width) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(TDdepth, $feature.Feat_depth) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(TDbasesub, $feature.Base_sub) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(TDflowpres, $feature.flow_pres) &amp;gt; -1, "TD",
      IndexOf(SDwidth, $feature.Feat_width) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(SDdepth, $feature.Feat_depth) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(SDbasesub, $feature.Base_sub) &amp;gt; -1, "SD",
      IndexOf(MDwidth, $feature.Feat_width) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(MDdepth, $feature.Feat_depth) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(MDbasesub, $feature.Base_sub) &amp;gt; -1, "MD",
      "Unknown")&lt;/LI-CODE&gt;&lt;P&gt;You could also use individual if functions, with a final return "Unknown" when none of the conditions are met, if that makes it easier to read&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var PBwidth = ["3m4m","4m"];
var PBdepth = ["1m","1m2m", "2m3m","3m4m","4m"];
var PBbasesub = ["BDP","VDP"];

if (IndexOf(PBwidth, $feature.Feat_width) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(PBdepth, $feature.Feat_depth) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(PBbasesub, $feature.Base_sub) &amp;gt; -1) return "PB";

var SBwidth = ["3m4m","4m"];
var SBdepth = ["1m","1m2m", "2m3m", "3m4m","4m"];
var SBbasesub = ["BM","VM","VSP","VSM","VSP"];

if (IndexOf(SBwidth, $feature.Feat_width) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(SBdepth, $feature.Feat_depth) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(SBbasesub, $feature.Base_sub) &amp;gt; -1) return "SB";

var PDwidth = ["1m","1m2m", "2m3m"];
var PDdepth = ["1m","1m2m", "2m3m", "3m4m","4m"];
var PDbasesub = ["BDP","VDP"];

if (IndexOf(PDwidth, $feature.Feat_width) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(PDdepth, $feature.Feat_depth) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(PDbasesub, $feature.Base_sub) &amp;gt; -1) return "PD";

var TDwidth = ["2m3m"];
var TDdepth = ["2m3m", "3m4m","4m"];
var TDbasesub = ["BDP","VDP"];
var TDflowpres = ["FP"];

if (IndexOf(TDwidth, $feature.Feat_width) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(TDdepth, $feature.Feat_depth) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(TDbasesub, $feature.Base_sub) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(TDflowpres, $feature.flow_pres) &amp;gt; -1) return "TD";

var SDwidth = ["1m","1m2m", "2m3m"];
var SDdepth = ["1m","1m2m", "2m3m", "3m4m","4m"];
var SDbasesub = ["VSM","VM","BM"];

if (IndexOf(SDwidth, $feature.Feat_width) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(SDdepth, $feature.Feat_depth) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(SDbasesub, $feature.Base_sub) &amp;gt; -1) return "SD";

var MDwidth = ["1m","1m2m", "2m3m"];
var MDdepth = ["1m","1m2m", "2m3m", "3m4m","4m"];
var MDbasesub = ["VSP","PSS","PSD"];

if (IndexOf(MDwidth, $feature.Feat_width) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(MDdepth, $feature.Feat_depth) &amp;gt; -1 &amp;amp;&amp;amp; IndexOf(MDbasesub, $feature.Base_sub) &amp;gt; -1) return "MD";

return "Unknown";&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2024 18:55:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-to-populate-field-based-on/m-p/1557556#M90043</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-11-12T18:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to populate field based on values in multiple other fields</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-to-populate-field-based-on/m-p/1557562#M90045</link>
      <description>&lt;P&gt;You could also consolidate your arrays with something like this, but you might prefer the more verbose method, which is easier to understand.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;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"];&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 12 Nov 2024 15:43:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-expression-to-populate-field-based-on/m-p/1557562#M90045</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-11-12T15:43:26Z</dc:date>
    </item>
  </channel>
</rss>

