<?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: Filter not working in arcade expression in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/filter-not-working-in-arcade-expression/m-p/1414145#M9465</link>
    <description>&lt;P&gt;Querying dates in SQL can be picky, especially if there is time involved. In some testing I was doing on my data, if I queried it using "Date = '07/10/2016'", it would return 0 features. If I queried using "Date &amp;gt; '07/10/2016' AND DATE1 &amp;lt;= '07/11/2016'", it would return 29 records. The query "cast(Date1 as date) = cast('7/10/2016' as date)" also returned 29 records. However, there are 36 records on that date, since I have several records after 8 pm ET (which is after midnight on the next day in UTC).&lt;/P&gt;&lt;P&gt;This query finally returned all 36 records&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var offset = -TimeZoneOffset(Now()); //returns time zone offset in milliseconds. Use - for Western Hemisphere
var startDate = DateAdd(Date(2016,06,10), offset, 'milliseconds');
var endDate = DateAdd(startDate, 1, 'day');
var filtered = Filter(fs, "Date1 &amp;gt; @startDate AND DATE1 &amp;lt;= @endDate");
return (Orderby(filtered, 'Date1 ASC'));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 23 Apr 2024 15:39:14 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2024-04-23T15:39:14Z</dc:date>
    <item>
      <title>Filter not working in arcade expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/filter-not-working-in-arcade-expression/m-p/1413702#M9461</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone tell me what I'm doing wrong? Still very new to arcade and trying to get a custom dashboard indicator with an expression.&lt;/P&gt;&lt;P&gt;I know I need to return a featureset to get it into a dashboard, I just haven't gotten to that point yet.&lt;/P&gt;&lt;P&gt;First, I need to figure out why my filter is not working. If I put EditDate IS NULL, I get the correct number of features (0):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SarahW2799_0-1713813197099.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/101725iF7C675162D6A0C0C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SarahW2799_0-1713813197099.png" alt="SarahW2799_0-1713813197099.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I just can't figure out how to format to count features where EditDate&amp;nbsp;is equal to 04/22/2024.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SarahW2799_1-1713813298032.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/101726i55A450E04D60B055/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SarahW2799_1-1713813298032.png" alt="SarahW2799_1-1713813298032.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I attached a screenshot of the table with the field and attribute I'm trying to filter.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SarahW2799_2-1713813354664.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/101727i07B18386FD874570/image-size/large?v=v2&amp;amp;px=999" role="button" title="SarahW2799_2-1713813354664.png" alt="SarahW2799_2-1713813354664.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I want to count all the features where the EditDate field is equal to 04/22/2024. This field is a text type. There is no field name alias. There is no domain.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;var features_washington = FeatureSetByPortalItem(
  Portal('https://www.arcgis.com'),
  'e5dd4d84533b49e1978abbd23228b6b7');

  var total = Count(Filter(features_washington, 'EditDate = 04/22/2024'));
  return total&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 19:18:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/filter-not-working-in-arcade-expression/m-p/1413702#M9461</guid>
      <dc:creator>SarahW2799</dc:creator>
      <dc:date>2024-04-22T19:18:59Z</dc:date>
    </item>
    <item>
      <title>Re: Filter not working in arcade expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/filter-not-working-in-arcade-expression/m-p/1413740#M9462</link>
      <description>&lt;P&gt;I think it might just be that you're missing quotes within your SQL statement since that field is text.&lt;/P&gt;&lt;P&gt;In your Filter statement, try Filter(features_washington, "EditDate = '04/22/2024'")&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 20:18:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/filter-not-working-in-arcade-expression/m-p/1413740#M9462</guid>
      <dc:creator>marksm_macomb</dc:creator>
      <dc:date>2024-04-22T20:18:09Z</dc:date>
    </item>
    <item>
      <title>Re: Filter not working in arcade expression</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/filter-not-working-in-arcade-expression/m-p/1414145#M9465</link>
      <description>&lt;P&gt;Querying dates in SQL can be picky, especially if there is time involved. In some testing I was doing on my data, if I queried it using "Date = '07/10/2016'", it would return 0 features. If I queried using "Date &amp;gt; '07/10/2016' AND DATE1 &amp;lt;= '07/11/2016'", it would return 29 records. The query "cast(Date1 as date) = cast('7/10/2016' as date)" also returned 29 records. However, there are 36 records on that date, since I have several records after 8 pm ET (which is after midnight on the next day in UTC).&lt;/P&gt;&lt;P&gt;This query finally returned all 36 records&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var offset = -TimeZoneOffset(Now()); //returns time zone offset in milliseconds. Use - for Western Hemisphere
var startDate = DateAdd(Date(2016,06,10), offset, 'milliseconds');
var endDate = DateAdd(startDate, 1, 'day');
var filtered = Filter(fs, "Date1 &amp;gt; @startDate AND DATE1 &amp;lt;= @endDate");
return (Orderby(filtered, 'Date1 ASC'));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2024 15:39:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/filter-not-working-in-arcade-expression/m-p/1414145#M9465</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-04-23T15:39:14Z</dc:date>
    </item>
  </channel>
</rss>

