<?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 Problem with &amp;quot;If, Else&amp;quot; in Arcade expression in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/problem-with-quot-if-else-quot-in-arcade/m-p/75855#M3618</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Im sure that this is a basic question so thanks in advance. I currently have an Arcade expression within a Javascript API WebApp that determines if a feature meets a DateDiff expression. The results from the Arcade expression are then sent to a UniqueValueRenderer within the app.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;var currentExpired = "IIf(DateDiff(Date(),$feature.DATERECEIVED,'days') &amp;gt; 365, 'Expired', 'Current')"&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to add a third condition and have written the following (though not truly in Arcade):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;var currentExpired = (DateDiff(Date(),$feature.DATERECEIVED,'days'))&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt; if (currentExpired &amp;gt; '365') {&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt; return 'Expired';&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt; } else if (currentExpired &amp;lt; '7') {&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt; return 'Upcoming';&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt; } else {&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt; return 'Current';&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt; }&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt; &amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to symbolize features that have a DATERECEIVED greater than 365 as 'Expired', those that are less than 7 days as upcoming, and everything else as current. Unfortunately, the logic seems to be flawed in that&amp;nbsp;the upcoming features being symbolized are those that have been received within the last 7 days. Where have I gone wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, any ideas on how to write the expression in a truly Arcade format?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 08 Feb 2019 19:04:04 GMT</pubDate>
    <dc:creator>PeterKing</dc:creator>
    <dc:date>2019-02-08T19:04:04Z</dc:date>
    <item>
      <title>Problem with "If, Else" in Arcade expression</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/problem-with-quot-if-else-quot-in-arcade/m-p/75855#M3618</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Im sure that this is a basic question so thanks in advance. I currently have an Arcade expression within a Javascript API WebApp that determines if a feature meets a DateDiff expression. The results from the Arcade expression are then sent to a UniqueValueRenderer within the app.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;var currentExpired = "IIf(DateDiff(Date(),$feature.DATERECEIVED,'days') &amp;gt; 365, 'Expired', 'Current')"&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to add a third condition and have written the following (though not truly in Arcade):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;var currentExpired = (DateDiff(Date(),$feature.DATERECEIVED,'days'))&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt; if (currentExpired &amp;gt; '365') {&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt; return 'Expired';&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt; } else if (currentExpired &amp;lt; '7') {&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt; return 'Upcoming';&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt; } else {&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt; return 'Current';&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt; }&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt; &amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to symbolize features that have a DATERECEIVED greater than 365 as 'Expired', those that are less than 7 days as upcoming, and everything else as current. Unfortunately, the logic seems to be flawed in that&amp;nbsp;the upcoming features being symbolized are those that have been received within the last 7 days. Where have I gone wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, any ideas on how to write the expression in a truly Arcade format?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Feb 2019 19:04:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/problem-with-quot-if-else-quot-in-arcade/m-p/75855#M3618</guid>
      <dc:creator>PeterKing</dc:creator>
      <dc:date>2019-02-08T19:04:04Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with "If, Else" in Arcade expression</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/problem-with-quot-if-else-quot-in-arcade/m-p/75856#M3619</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You've put the number in quotes, meaning they're being evaluated as strings. Try this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; currentExpired &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;DateDiff&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Date&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;$feature&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;DATERECEIVED&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'days'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;currentExpired &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;365&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
  &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'Expired'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;currentExpired &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;7&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
  &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'Upcoming'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
  &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'Current'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;‍‍‍‍‍‍‍‍&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:56:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/problem-with-quot-if-else-quot-in-arcade/m-p/75856#M3619</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2021-12-10T22:56:15Z</dc:date>
    </item>
  </channel>
</rss>

