<?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 Multiple values for condition in IIF attribute rule statement in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/multiple-values-for-condition-in-iif-attribute/m-p/582313#M25660</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to create an immediate calculation attribute rule for a feature class in ArcGIS Pro (that I hope carries over when published as a feature service on AGOL).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I understand the basic syntax: IIF(condition, trueValue, falseValue). So if I wanted to create a rule that would take a value in my fictitious FoodName field and auto-calculate my FoodType field, I could do some thing like...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;var food = $feature.FoodName
IIF(food == 'Carrot', 'Vegetable', 'Fruit')&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This would, whenever the value 'Carrot' appears in the FoodName field, calculate the FoodType field to 'Vegetable.' My question: How do you pass a list of values to the condition in these statements? This has been surprisingly not straight forward to find online.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For instance, I would like the values 'Carrot', 'Celery', 'Parsnip', and 'Broccoli' to&amp;nbsp;&lt;EM&gt;all&lt;/EM&gt; to auto calculate to 'Vegetable.' Is it possible to pass a list to the condition, rather than writing multiple IIF statements? What is the preferred syntax?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 01:02:01 GMT</pubDate>
    <dc:creator>SFM_TravisBott</dc:creator>
    <dc:date>2021-12-12T01:02:01Z</dc:date>
    <item>
      <title>Multiple values for condition in IIF attribute rule statement</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/multiple-values-for-condition-in-iif-attribute/m-p/582313#M25660</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to create an immediate calculation attribute rule for a feature class in ArcGIS Pro (that I hope carries over when published as a feature service on AGOL).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I understand the basic syntax: IIF(condition, trueValue, falseValue). So if I wanted to create a rule that would take a value in my fictitious FoodName field and auto-calculate my FoodType field, I could do some thing like...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;var food = $feature.FoodName
IIF(food == 'Carrot', 'Vegetable', 'Fruit')&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This would, whenever the value 'Carrot' appears in the FoodName field, calculate the FoodType field to 'Vegetable.' My question: How do you pass a list of values to the condition in these statements? This has been surprisingly not straight forward to find online.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For instance, I would like the values 'Carrot', 'Celery', 'Parsnip', and 'Broccoli' to&amp;nbsp;&lt;EM&gt;all&lt;/EM&gt; to auto calculate to 'Vegetable.' Is it possible to pass a list to the condition, rather than writing multiple IIF statements? What is the preferred syntax?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:02:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/multiple-values-for-condition-in-iif-attribute/m-p/582313#M25660</guid>
      <dc:creator>SFM_TravisBott</dc:creator>
      <dc:date>2021-12-12T01:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple values for condition in IIF attribute rule statement</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/multiple-values-for-condition-in-iif-attribute/m-p/582314#M25661</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A couple different ways to tackle this type of situation.&amp;nbsp; If you want to stick with arrays instead of dictionaries, membership lookup is through IndexOf&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;var veggies = ['Carrot', 'Celery', 'Parsnip', 'Broccoli']
var items = ['Parsnip', 'Apple']

for (var k in items) {
    Console(IIf(IndexOf(veggies, items&lt;K&gt;) &amp;gt; -1, 'Vegetable', 'Fruit'))
}

Use Console Function to output messages.

Vegetable
Fruit‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/K&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:02:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/multiple-values-for-condition-in-iif-attribute/m-p/582314#M25661</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-12T01:02:04Z</dc:date>
    </item>
  </channel>
</rss>

