<?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 Dashboard - Today Date Unless data is blank in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1109412#M5257</link>
    <description>&lt;P&gt;I am looking for help with a script to display only todays data unless todays data has not been displayed yet. If that is the case display yesterday data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am thinking it would be if today &amp;gt; 0 display today data if not display today-1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Oct 2021 19:38:29 GMT</pubDate>
    <dc:creator>RickeyFight</dc:creator>
    <dc:date>2021-10-20T19:38:29Z</dc:date>
    <item>
      <title>Dashboard - Today Date Unless data is blank</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1109412#M5257</link>
      <description>&lt;P&gt;I am looking for help with a script to display only todays data unless todays data has not been displayed yet. If that is the case display yesterday data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am thinking it would be if today &amp;gt; 0 display today data if not display today-1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 19:38:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1109412#M5257</guid>
      <dc:creator>RickeyFight</dc:creator>
      <dc:date>2021-10-20T19:38:29Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - Today Date Unless data is blank</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1109416#M5258</link>
      <description>&lt;P&gt;Are you doing this in a data expression? Or working with an existing layer? The former is possible, but the latter probably isn't.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 19:47:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1109416#M5258</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-10-20T19:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - Today Date Unless data is blank</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1109448#M5260</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to do this in a data expression.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 20:53:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1109448#M5260</guid>
      <dc:creator>RickeyFight</dc:creator>
      <dc:date>2021-10-20T20:53:20Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - Today Date Unless data is blank</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1109465#M5262</link>
      <description>&lt;P&gt;Ah, well that's not too bad. It's very similar to the example &lt;A href="https://github.com/Esri/arcade-expressions/blob/master/dashboard_data/MostRecentRecords(IndicatorOrGuage).md" target="_self"&gt;shown here&lt;/A&gt;.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Get layer
var portal = Portal('org-url')
var fs = FeatureSetByPortalItem(
    portal,
    'itemID',
    0, // or whatever the layer index
    [
        'your',
        'fields',
        'some_date_field'
    ],
    false
);

// Get most recent date, convert to SQL-compatible string
var maxDate = Text(Date(fs, 'some_date_field'), 'YYYY-MM-DD');

// Return records for max date
return Filter(fs, "some_date_field = @maxDate")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 21:33:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1109465#M5262</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-10-20T21:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - Today Date Unless data is blank</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1109475#M5264</link>
      <description>&lt;P&gt;Thanks for the link.&amp;nbsp;&lt;/P&gt;&lt;P&gt;One issue I have is that I have pre added dates for the year so I cannot pick the max date but maybe I can get it to work with todays date.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Oct 2021 22:03:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1109475#M5264</guid>
      <dc:creator>RickeyFight</dc:creator>
      <dc:date>2021-10-20T22:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - Today Date Unless data is blank</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1109479#M5265</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Get layer
var portal = Portal('org-url')
var fs = FeatureSetByPortalItem(
    portal,
    'itemID',
    0, // or whatever the layer index
    [
        'your',
        'fields',
        'some_date_field',
        'some_value_field'
    ],
    false
);

// Filter records with empty values (future dates)
var filt = Filter(fs, "some_value_field IS NOT NULL AND some_value_field &amp;lt;&amp;gt; ''")

// Sort filtered records for most recent first
var sorted = OrderBy(filt, "some_date_field DESC")

// Return top record
return First(sorted)&lt;/LI-CODE&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/40123"&gt;@RickeyFight&lt;/a&gt;you're right, that was it. Though the AND was probably part of it, too. I've edited this code so that the &lt;STRONG&gt;OrderBy&lt;/STRONG&gt; references &lt;STRONG&gt;filt&lt;/STRONG&gt; instead of &lt;STRONG&gt;fs&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 15:00:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1109479#M5265</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-10-22T15:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - Today Date Unless data is blank</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1109723#M5272</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// Filter records with empty values (future dates)
var filt = Filter(fs, "REEDER_Percent_FULL IS NOT NULL REEDER_Percent_FULL &amp;lt;&amp;gt; ''")
 
// Sort filtered records for most recent first
var sorted = OrderBy(fs, "Date_ DESC")

// Return top record
return First(sorted)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have so far.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am getting this error:&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Execution Error:&lt;/SPAN&gt;&lt;SPAN&gt;Expected "*", "+", "-", "/", "AND", "OR", [ \t\n\r], or end of input but "R" found.&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Oct 2021 14:52:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1109723#M5272</guid>
      <dc:creator>RickeyFight</dc:creator>
      <dc:date>2021-10-21T14:52:31Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - Today Date Unless data is blank</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1109942#M5275</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am now getting data to display but it is still showing the Null data. How does the var filt apply to the sorted layer?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RickeyFight_0-1634847565700.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/25802i8627E4733676C6A6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RickeyFight_0-1634847565700.png" alt="RickeyFight_0-1634847565700.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Oct 2021 20:28:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1109942#M5275</guid>
      <dc:creator>RickeyFight</dc:creator>
      <dc:date>2021-10-21T20:28:29Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - Today Date Unless data is blank</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1110228#M5278</link>
      <description>&lt;P&gt;You need an "AND" before the second statement in your SQL.&lt;/P&gt;&lt;P&gt;"...IS NOT NULL &lt;STRONG&gt;AND &lt;/STRONG&gt;REEDER&lt;STRONG&gt;_&lt;/STRONG&gt;Percent_FULL..."&lt;/P&gt;&lt;P&gt;EDIT: Change that to AND.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 13:58:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1110228#M5278</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-10-22T13:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - Today Date Unless data is blank</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1110233#M5280</link>
      <description>&lt;P&gt;I edited my reply below, but I think we want an "AND" in the SQL statement, not "OR". Something that has a value of '', that is, an empty string, will still satisfy the "IS NOT NULL" condition, allowing it through. My mistake!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 13:59:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1110233#M5280</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-10-22T13:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - Today Date Unless data is blank</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1110274#M5287</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your continued help on this.&lt;/P&gt;&lt;P&gt;I am not sure the "AND" is the issue. I added the change and this is what I get. I think the problem is that the "filt" var is defined but then not put into the result. I would think that the "sorted" var would need to reference the "filt" var at some point.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RickeyFight_0-1634914484041.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/25900i6B066C8AA5FB1D4F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RickeyFight_0-1634914484041.png" alt="RickeyFight_0-1634914484041.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 14:56:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1110274#M5287</guid>
      <dc:creator>RickeyFight</dc:creator>
      <dc:date>2021-10-22T14:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - Today Date Unless data is blank</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1110299#M5289</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;I get this now&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RickeyFight_0-1634916925938.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/25906i77B7F031CD14CB53/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RickeyFight_0-1634916925938.png" alt="RickeyFight_0-1634916925938.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 15:35:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1110299#M5289</guid>
      <dc:creator>RickeyFight</dc:creator>
      <dc:date>2021-10-22T15:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - Today Date Unless data is blank</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1110305#M5290</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var portal = Portal("PortalID");
var fs = FeatureSetByPortalItem(
  portal,
  "Numbers",
  1,
  [
    "Date_",
    "W_F_MGD",
    "E_F_MGD",
    "TOTAL_W_E_MGD",
    "TID_FLOW_MGD",
    "REEDER_Percent_FULL",
    "TAP_FLOW_MGD",
    "PLANT_PRODUCTION_MGD",
    "last_edited_date"
  ],
  false
);



// Filter records with empty values (future dates)
var filt = Filter(fs, "REEDER_Percent_FULL IS NOT NULL OR REEDER_Percent_FULL &amp;lt;&amp;gt; ''")

// Sort filtered records for most recent first
var sorted = OrderBy(filt, "Date_ DESC")

// Return top record
return First(sorted)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my full code minus the portal login info&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 15:40:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1110305#M5290</guid>
      <dc:creator>RickeyFight</dc:creator>
      <dc:date>2021-10-22T15:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - Today Date Unless data is blank</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1110311#M5292</link>
      <description>&lt;P&gt;Hmmm. Try throwing in some &lt;STRONG&gt;Console&lt;/STRONG&gt; commands to output some intermediate things, try to see where it's failing.&lt;/P&gt;&lt;PRE&gt;After ln 18: Console(fs)&lt;BR /&gt;After ln 23: Console(filt)&lt;BR /&gt;After ln 26: Console(sorted)&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Oct 2021 15:42:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1110311#M5292</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-10-22T15:42:54Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - Today Date Unless data is blank</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1110323#M5294</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;I think you were almost right.&amp;nbsp;&lt;BR /&gt;This is what I got to work&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// Filter records with empty values (future dates)
var filt = Filter(fs, "REEDER_Percent_FULL IS NOT NULL")

// Sort filtered records for most recent first
var sorted = OrderBy(filt, "Date_ DESC")

// Return top record
return First(sorted)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you modify your post I will mark yours as correct&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 16:03:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1110323#M5294</guid>
      <dc:creator>RickeyFight</dc:creator>
      <dc:date>2021-10-22T16:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - Today Date Unless data is blank</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1110325#M5295</link>
      <description>&lt;P&gt;Always tricky to debug to without having access to the data. Glad you got it working!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 16:06:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1110325#M5295</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-10-22T16:06:07Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard - Today Date Unless data is blank</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1110327#M5296</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got it to work once.&amp;nbsp; When I test I get the results I want but the script picker now gives me this error&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RickeyFight_0-1634918876958.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/25911iBF1D9EED7FC8C866/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RickeyFight_0-1634918876958.png" alt="RickeyFight_0-1634918876958.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Oct 2021 16:08:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/dashboard-today-date-unless-data-is-blank/m-p/1110327#M5296</guid>
      <dc:creator>RickeyFight</dc:creator>
      <dc:date>2021-10-22T16:08:04Z</dc:date>
    </item>
  </channel>
</rss>

