<?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: Creating Status using Arcade in Dashboards in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/creating-status-using-arcade-in-dashboards/m-p/1252086#M7260</link>
    <description>&lt;P&gt;Thank you for your reply!&amp;nbsp; I plugged this into the data expression and this error returned:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Expected "!=", "*", "+", "-", "/", "&amp;lt;", "&amp;lt;=", "&amp;lt;&amp;gt;", "=", "&amp;gt;", "&amp;gt;=", "AND", "BETWEEN", "END", "IN", "IS", "LIKE", "NOT", "OR", or [ \t\n\r] but end of input found.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I'm not super savvy with Arcade and have taken a few trainings.&amp;nbsp; My dashboard itself is very simple, it consists of a map, list, and indicator showing active projects. I could add a pie chart to accomplish the filter you are referring to.&amp;nbsp; I was also hoping there was a way I could have the default of the map only show active projects when it is initially opened.&amp;nbsp; I know that kind of functionality exists with the category selector and that's why I was looking to go that route.&amp;nbsp; Any other ideas on how to accomplish this are greatly appreciated.&lt;/P&gt;</description>
    <pubDate>Thu, 26 Jan 2023 20:41:14 GMT</pubDate>
    <dc:creator>BNix_TPA</dc:creator>
    <dc:date>2023-01-26T20:41:14Z</dc:date>
    <item>
      <title>Creating Status using Arcade in Dashboards</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/creating-status-using-arcade-in-dashboards/m-p/1252017#M7258</link>
      <description>&lt;P&gt;I'm trying to create a project status, but don't want to store the status in the data.&amp;nbsp; I want the status to automatically change when the date passes to be complete.&amp;nbsp; I was able to set up my map and symbolize the features based on this new status.&amp;nbsp; I now want to use the same status within my dashboard as a category picker.&amp;nbsp; How would I use this code within a dashboard?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;started&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;$feature&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Startdate_time&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;closed&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;$feature&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Enddate_time&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;present&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;Now&lt;/SPAN&gt;&lt;SPAN&gt;()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;If&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;present&lt;/SPAN&gt;&lt;SPAN&gt; &amp;gt;= &lt;/SPAN&gt;&lt;SPAN&gt;started&lt;/SPAN&gt;&lt;SPAN&gt; &amp;amp;&amp;amp; &lt;/SPAN&gt;&lt;SPAN&gt;present&lt;/SPAN&gt;&lt;SPAN&gt; &amp;lt;= &lt;/SPAN&gt;&lt;SPAN&gt;closed&lt;/SPAN&gt;&lt;SPAN&gt;) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt; &lt;SPAN&gt;"Active"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;} &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;If&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;present&lt;/SPAN&gt;&lt;SPAN&gt; &amp;lt;= &lt;/SPAN&gt;&lt;SPAN&gt;started&lt;/SPAN&gt;&lt;SPAN&gt;) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt; &lt;SPAN&gt;"Planned"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;} &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;else&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt; &lt;SPAN&gt;"Closed"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 26 Jan 2023 18:50:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/creating-status-using-arcade-in-dashboards/m-p/1252017#M7258</guid>
      <dc:creator>BNix_TPA</dc:creator>
      <dc:date>2023-01-26T18:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Status using Arcade in Dashboards</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/creating-status-using-arcade-in-dashboards/m-p/1252041#M7259</link>
      <description>&lt;P&gt;To get this calculated value as a category, it needs to be a real field. Not to worry, though, as a Data Expression can "bake in" the field without needing to really create it in the layer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSetByPortalItem(
    Portal('your portal url'),
    'itemid of service',
    0,
    ['Startdate_time', 'Enddate_time'],
    false
)

var sql = `CASE
WHEN CURRENT_TIME() &amp;gt;= Startdate_time AND CURRENT_TIME() &amp;lt;= Enddate_time THEN 'Active'
WHEN CURRENT_TIME() &amp;lt;= Startdate_time THEN 'Planned'
ELSE 'Closed'
END`

return Distinct(
    fs,
    [
        {name: 'objectid', expression: 'objectid'},
        {name: 'status', expression: sql}
    ]
)
        &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You'll need the picker to hook into the data expression, as opposed to the layer. The trouble, though, is that the way category selectors work is &lt;EM&gt;based on field values&lt;/EM&gt;. So even if you got this into your picker, you won't be able to use it against the original layer.&lt;/P&gt;&lt;P&gt;It would still work if you used the Data Expression layer in all your other widgets, though. Just add extra fields to the &lt;STRONG&gt;Distinct&lt;/STRONG&gt; function to make them available to the output. What other widgets are in your dashboard?&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 20:57:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/creating-status-using-arcade-in-dashboards/m-p/1252041#M7259</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-01-26T20:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Status using Arcade in Dashboards</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/creating-status-using-arcade-in-dashboards/m-p/1252086#M7260</link>
      <description>&lt;P&gt;Thank you for your reply!&amp;nbsp; I plugged this into the data expression and this error returned:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Expected "!=", "*", "+", "-", "/", "&amp;lt;", "&amp;lt;=", "&amp;lt;&amp;gt;", "=", "&amp;gt;", "&amp;gt;=", "AND", "BETWEEN", "END", "IN", "IS", "LIKE", "NOT", "OR", or [ \t\n\r] but end of input found.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I'm not super savvy with Arcade and have taken a few trainings.&amp;nbsp; My dashboard itself is very simple, it consists of a map, list, and indicator showing active projects. I could add a pie chart to accomplish the filter you are referring to.&amp;nbsp; I was also hoping there was a way I could have the default of the map only show active projects when it is initially opened.&amp;nbsp; I know that kind of functionality exists with the category selector and that's why I was looking to go that route.&amp;nbsp; Any other ideas on how to accomplish this are greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 20:41:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/creating-status-using-arcade-in-dashboards/m-p/1252086#M7260</guid>
      <dc:creator>BNix_TPA</dc:creator>
      <dc:date>2023-01-26T20:41:14Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Status using Arcade in Dashboards</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/creating-status-using-arcade-in-dashboards/m-p/1252094#M7261</link>
      <description>&lt;P&gt;D'oh! A &lt;STRONG&gt;Case&lt;/STRONG&gt; statement needs an &lt;STRONG&gt;End&lt;/STRONG&gt;. I will edit the code block in the original post. Just put the word END right after 'Closed' in the SQL string.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2023 20:57:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/creating-status-using-arcade-in-dashboards/m-p/1252094#M7261</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2023-01-26T20:57:12Z</dc:date>
    </item>
  </channel>
</rss>

