<?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 calculated expression help in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-calculated-expression-help/m-p/1254807#M50122</link>
    <description>&lt;P&gt;Johannes you are a star! Thank you!&amp;nbsp; Using your solution has worked perfectly.&lt;/P&gt;</description>
    <pubDate>Fri, 03 Feb 2023 13:10:00 GMT</pubDate>
    <dc:creator>Lee_Butler</dc:creator>
    <dc:date>2023-02-03T13:10:00Z</dc:date>
    <item>
      <title>Arcade calculated expression help</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-calculated-expression-help/m-p/1254791#M50120</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I hoping to get some help with a bit of Arcade code I'm using to calculate a value for another field.&lt;/P&gt;&lt;P&gt;I have a field, TargetExchange which a user populates with a date dd/mm/yyyy.&amp;nbsp; I want the arcade expression to caluclate the FinacialYear field based on the date entered.&amp;nbsp; I have set this up in the layers form but when I test by entering a date in the TargetExchange field I am only recieving a "None" value in the FinancialYear field.&amp;nbsp; Any ideas where I have gone wrong:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;var dates = $feature.TargetExchange&lt;BR /&gt;var financialYear = When(&lt;BR /&gt;&amp;nbsp;&amp;nbsp; dates &amp;gt;= 01/04/2023 &amp;amp;&amp;amp; dates &amp;lt; 01/04/2024, "2023/2024",&lt;BR /&gt;&amp;nbsp;&amp;nbsp; dates &amp;gt;= 01/04/2024 &amp;amp;&amp;amp; dates &amp;lt; 01/04/2025, "2024/2025",&lt;BR /&gt;&amp;nbsp;&amp;nbsp; dates &amp;gt;= 01/04/2025 &amp;amp;&amp;amp; dates &amp;lt; 01/04/2026, "2025/2026",&lt;BR /&gt;&amp;nbsp;&amp;nbsp; dates &amp;gt;= 01/04/2026 &amp;amp;&amp;amp; dates &amp;lt; 01/04/2027, "2026/2027",&lt;BR /&gt;&amp;nbsp;&amp;nbsp; dates &amp;gt;= 01/04/2027 &amp;amp;&amp;amp; dates &amp;lt; 01/04/2028, "2027/2028",&lt;BR /&gt;&amp;nbsp;&amp;nbsp; dates &amp;gt;= 01/04/2028 &amp;amp;&amp;amp; dates &amp;lt; 01/04/2029, "2028/2029",&lt;BR /&gt;&amp;nbsp;&amp;nbsp; dates &amp;gt;= 01/04/2029 &amp;amp;&amp;amp; dates &amp;lt; 01/04/2030, "2029/2030",&lt;BR /&gt;&amp;nbsp;&amp;nbsp; "None")&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;return financialYear&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Lee&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 11:18:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-calculated-expression-help/m-p/1254791#M50120</guid>
      <dc:creator>Lee_Butler</dc:creator>
      <dc:date>2023-02-03T11:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade calculated expression help</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-calculated-expression-help/m-p/1254798#M50121</link>
      <description>&lt;P&gt;It doesn't work because you're not comparing to a date. Instead you compare a date (a very large number - &lt;SPAN&gt;milliseconds since January 1, 1970 UTC) to a very small number (1/4/2024 =&amp;nbsp;0.00012).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Instead, you have to compare to actual dates:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// month is 0 based -&amp;gt; January = 0, April = 3

var financialYear = When(
   dates &amp;gt;= Date(2023, 3, 1) &amp;amp;&amp;amp; dates &amp;lt; Date(2024, 3, 1), "2023/2024",
   // ...
   "None")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is very cumbersome. A better way:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var dates = $feature.TargetExchange
var y = Year(dates)
var m = Month(dates)
return IIf(
    m &amp;gt;= 3,        // if after April
    `${y}/${y+1}`, // use "current/next"
    `${y-1}/${y}`) // else use "previous/current"&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 03 Feb 2023 12:22:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-calculated-expression-help/m-p/1254798#M50121</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-02-03T12:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade calculated expression help</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-calculated-expression-help/m-p/1254807#M50122</link>
      <description>&lt;P&gt;Johannes you are a star! Thank you!&amp;nbsp; Using your solution has worked perfectly.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 13:10:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-calculated-expression-help/m-p/1254807#M50122</guid>
      <dc:creator>Lee_Butler</dc:creator>
      <dc:date>2023-02-03T13:10:00Z</dc:date>
    </item>
  </channel>
</rss>

