<?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 Re: Arcade Expression Multiple Conditions in IF blocks in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-multiple-conditions-in-if-blocks/m-p/1276703#M51349</link>
    <description>&lt;P&gt;Give this a try. It is using nested ifs, but it might be easier to understand.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var output = 'Fail';
if (!IsEmpty($feature.feature.Run_Slope1_PC)) {
   if ($feature.feature.Run_Slope1_PC &amp;lt;= 5) {
      if ($feature.ramp_style == 'Blended_Transition' || $feature.ramp_style == 'Cut_Through') output = 'Pass'
   } else if ($feature.feature.Run_Slope1_PC &amp;lt;= 8.3) output = 'Pass'
}
return output;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Apr 2023 20:37:53 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2023-04-07T20:37:53Z</dc:date>
    <item>
      <title>Arcade Expression Multiple Conditions in IF blocks</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-multiple-conditions-in-if-blocks/m-p/1276696#M51348</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm hoping you can help me out with this Arcade expression. I have an inspection form in ArcGIS FieldMaps that needs to calculate whether or not something is "passing" based on multiple conditions.&lt;/P&gt;&lt;P&gt;I'm having trouble with the nested IF statements failing to calculate in FieldMaps. I need to write an expression to say:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Slope 1 is passing IF slope percentage is not null and less than or equal to 8.3,&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;BUT if the style is Blended Transition or Cut Through, then it is only passing if the slope percentage&amp;nbsp;is less than or equal to 5.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;My expression so far is:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if (($feature.ramp_style =='Blended_Transition'||$feature.ramp_style == 'Cut_Through')&amp;amp;&amp;amp;($feature.Run1_Slope_PC &amp;lt;=5) &amp;amp;&amp;amp; $feature.Run_Slope1_PC!=null) {
  return "Pass"
} else if (($feature.ramp_style!='Blended_Transition' &amp;amp;&amp;amp; $feature.ramp_style != 'Cut_Through')&amp;amp;&amp;amp;($feature.Run_Slope1_PC&amp;gt;0 &amp;amp;&amp;amp; $feature.Run_Slope1_PC&amp;lt;=8.3 &amp;amp;&amp;amp; $feature.Run_Slope1_PC!=null)) {
  return "Pass"
} else {
  return "Fail"
}&lt;/LI-CODE&gt;&lt;P&gt;The only error message I get is "Failed to Calculate" and "Exploded Map Package" in the FieldMaps troubleshooting logs.&lt;/P&gt;&lt;P&gt;I don't have much experience with nested if-else blocks so maybe I have my grammar wrong?&lt;/P&gt;&lt;P&gt;Thanks for all your help,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Caitlin&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 20:08:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-multiple-conditions-in-if-blocks/m-p/1276696#M51348</guid>
      <dc:creator>Caitlin_Todd_LCOR</dc:creator>
      <dc:date>2023-04-07T20:08:22Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression Multiple Conditions in IF blocks</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-multiple-conditions-in-if-blocks/m-p/1276703#M51349</link>
      <description>&lt;P&gt;Give this a try. It is using nested ifs, but it might be easier to understand.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var output = 'Fail';
if (!IsEmpty($feature.feature.Run_Slope1_PC)) {
   if ($feature.feature.Run_Slope1_PC &amp;lt;= 5) {
      if ($feature.ramp_style == 'Blended_Transition' || $feature.ramp_style == 'Cut_Through') output = 'Pass'
   } else if ($feature.feature.Run_Slope1_PC &amp;lt;= 8.3) output = 'Pass'
}
return output;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 20:37:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-multiple-conditions-in-if-blocks/m-p/1276703#M51349</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-04-07T20:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression Multiple Conditions in IF blocks</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-multiple-conditions-in-if-blocks/m-p/1276717#M51350</link>
      <description>&lt;P&gt;Hi thanks so much for the suggestion! Unfortunately it only halfway worked for what I needed it to do. It does let a slope be passing if the style is Blended Transition or Cut Through and &amp;lt;= 5, but it fails to calculate when the style isn't one of those two.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll keep trying with the format you provided and see if I can find a way to get it to work&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 21:36:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-multiple-conditions-in-if-blocks/m-p/1276717#M51350</guid>
      <dc:creator>Caitlin_Todd_LCOR</dc:creator>
      <dc:date>2023-04-07T21:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression Multiple Conditions in IF blocks</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-multiple-conditions-in-if-blocks/m-p/1276767#M51353</link>
      <description>&lt;P&gt;I've tried to simplify the logic by using return statements.&lt;/P&gt;&lt;P&gt;tested in&amp;nbsp;&lt;A href="https://developers.arcgis.com/arcade/playground/" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/arcade/playground/&lt;/A&gt;&amp;nbsp;with dummy variables and seems to work as intended.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//dummy values for testing 
var Run_Slope1_PC = 7
var ramp_style = 'Blended_Transition'

//if empty FAIL
if (IsEmpty(Run_Slope1_PC)) {
    return 'Fail'
}

//if &amp;gt;5 and (blendedT or CutThru) FAIL
if (Run_Slope1_PC &amp;gt; 5 &amp;amp;&amp;amp; (ramp_style == 'Blended_Transition' || ramp_style == 'Cut_Through')) { 
    return 'Fail'
}

//anything else &amp;lt;=8.3 PASS
if (Run_Slope1_PC &amp;lt;= 8.3) {
    return 'Pass'
}

else {
    return 'Fail'
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Apr 2023 11:39:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-multiple-conditions-in-if-blocks/m-p/1276767#M51353</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2023-04-09T11:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression Multiple Conditions in IF blocks</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-multiple-conditions-in-if-blocks/m-p/1276930#M51363</link>
      <description>&lt;P&gt;Ah, I had misread the requirements. This should work&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if (IsEmpty($feature.Run_Slope1_PC)) return 'Fail'
if ($feature.ramp_style == 'Blended_Transition' || $feature.ramp_style == 'Cut_Through') {
  if ($feature.Run_Slope1_PC &amp;lt;= 5) return 'Pass'
} else if ($feature.Run_Slope1_PC &amp;lt;= 8.3) return 'Pass'
return 'Fail';&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 10 Apr 2023 14:07:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-multiple-conditions-in-if-blocks/m-p/1276930#M51363</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-04-10T14:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression Multiple Conditions in IF blocks</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-multiple-conditions-in-if-blocks/m-p/1276999#M51368</link>
      <description>&lt;P&gt;David and Ken, both of those worked! Thank you both so much! You are Arcade geniuses.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I put Ken's as the solution since it's fewer lines.&lt;/P&gt;&lt;P&gt;Hope your weeks go smoothly&amp;nbsp;&lt;/P&gt;&lt;P&gt;Caitlin&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2023 17:30:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-multiple-conditions-in-if-blocks/m-p/1276999#M51368</guid>
      <dc:creator>Caitlin_Todd_LCOR</dc:creator>
      <dc:date>2023-04-10T17:30:55Z</dc:date>
    </item>
  </channel>
</rss>

