<?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 help categorize in ArcGIS Enterprise Portal Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-portal-questions/arcade-expression-to-help-categorize/m-p/1259437#M13214</link>
    <description>&lt;P&gt;I am trying to categorize data using arcade and dates.&amp;nbsp; It worked on a previous project but not working on the new dataset.&amp;nbsp; If the date is older than today - call it red.&amp;nbsp; If within 1 year - call it yellow and if over 1 year from now call it green.&amp;nbsp; I only seem to get one response of Red, but the data has values that should give me all three categories.&lt;/P&gt;&lt;P&gt;var year = DateDiff(Now(), $feature["Next_Audit_Date"],'years');&lt;BR /&gt;return When(year &amp;lt;= 1, 'Yellow', year &amp;gt; 1, 'Green', 'Red');&lt;/P&gt;</description>
    <pubDate>Fri, 17 Feb 2023 17:33:52 GMT</pubDate>
    <dc:creator>BobWheeler</dc:creator>
    <dc:date>2023-02-17T17:33:52Z</dc:date>
    <item>
      <title>Arcade expression to help categorize</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-portal-questions/arcade-expression-to-help-categorize/m-p/1259437#M13214</link>
      <description>&lt;P&gt;I am trying to categorize data using arcade and dates.&amp;nbsp; It worked on a previous project but not working on the new dataset.&amp;nbsp; If the date is older than today - call it red.&amp;nbsp; If within 1 year - call it yellow and if over 1 year from now call it green.&amp;nbsp; I only seem to get one response of Red, but the data has values that should give me all three categories.&lt;/P&gt;&lt;P&gt;var year = DateDiff(Now(), $feature["Next_Audit_Date"],'years');&lt;BR /&gt;return When(year &amp;lt;= 1, 'Yellow', year &amp;gt; 1, 'Green', 'Red');&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2023 17:33:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-portal-questions/arcade-expression-to-help-categorize/m-p/1259437#M13214</guid>
      <dc:creator>BobWheeler</dc:creator>
      <dc:date>2023-02-17T17:33:52Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to help categorize</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-portal-questions/arcade-expression-to-help-categorize/m-p/1259452#M13215</link>
      <description>&lt;P&gt;Are you sure you're getting a valid value from the DateDiff function? If it's an invalid number (NaN), then your When will return 'Red'. Otherwise, I can't see a way of getting 'Red' from the way your logic is set up. This code seems to be what you're trying to get. Note that you shouldn't use &lt;A href="https://developers.arcgis.com/arcade/guide/reserved/" target="_self"&gt;reserved words&lt;/A&gt; (like "year") for variable names.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var theYear = DateDiff($feature["Next_Audit_Date"], Now(), 'years');
console(theYear);
return When(theYear &amp;lt;= 0, 'Red', 
            theYear &amp;lt;= 1, 'Yellow', 
            theYear &amp;gt; 1, 'Green',
            'Invalid');&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2023 17:59:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-portal-questions/arcade-expression-to-help-categorize/m-p/1259452#M13215</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-02-17T17:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression to help categorize</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-portal-questions/arcade-expression-to-help-categorize/m-p/1259459#M13216</link>
      <description>&lt;P&gt;Ken - thanks for the advice on reserved words.&amp;nbsp; I will pay more attention to that.&amp;nbsp; Using your example in Pro provides the result I'm looking for.&amp;nbsp; I was attempting to apply with the MapViewer in on-prem Portal.&amp;nbsp; That still seems to fail, but I'll work around that.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2023 18:18:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-portal-questions/arcade-expression-to-help-categorize/m-p/1259459#M13216</guid>
      <dc:creator>BobWheeler</dc:creator>
      <dc:date>2023-02-17T18:18:05Z</dc:date>
    </item>
  </channel>
</rss>

