<?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 data based on most recent value from different categories within layer in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/filter-data-based-on-most-recent-value-from/m-p/1218616#M6873</link>
    <description>&lt;P&gt;A data expression would be the way I'd do it. And I think we could do all the necessary work within a&amp;nbsp;&lt;STRONG&gt;GroupBy&lt;/STRONG&gt; statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var portal = Portal('your url')

var fs = FeatureSetByPortalItem(
    portal,
    'itemid',
    0, // or whatever layer index it is
    ['teamID', 'date_created'],
    false
)

return GroupBy(fs,
    'teamID',
    {
        name: 'latest_entry',
        expression: 'date_created',
        statistic: 'MAX'
    }
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mind that this expression would only be returning the latest date for each team ID. If you wanted to get the data values for those corresponding entries, you'd need to do a bit more work.&lt;/P&gt;</description>
    <pubDate>Tue, 04 Oct 2022 13:56:08 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2022-10-04T13:56:08Z</dc:date>
    <item>
      <title>Filter data based on most recent value from different categories within layer</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/filter-data-based-on-most-recent-value-from/m-p/1218545#M6871</link>
      <description>&lt;P&gt;I have a survey123 survey that different teams have to fill out and submit on a daily basis. I am creating a dashboard to show information on survey submissions within the last 24 hours.&lt;/P&gt;&lt;P&gt;I can filter the data using the date/time of for submission, to be within the last 24 hours, either within the dashboard config itself, or by creating a view layer of the main survery123 feature layer.&lt;/P&gt;&lt;P&gt;One of the elements in my dashboard is a table, and as per the previous paragraph, this currently only has a row/record for teams that have submitted a survey within the last 24 hours. What I would like to display, is a table that has a row/record for every team that exists (whether they have submitted a survey within the last 24 hours or not), and then have some way of visualising the recency of their last submission.&lt;/P&gt;&lt;P&gt;One idea I had was to somehow filter the data on the most recent feature for each team’s name/ID value, so that there would only be 1 record per team, and then style the colour of the row based on whether it was in/out of the last 24 hours. However, I am struggling to identify a way to filter the data based on the most recent record per team.&lt;/P&gt;&lt;P&gt;I also wondered if there would be some way to do this by creating a data expression, but again I am not sure how this would work.&lt;/P&gt;&lt;P&gt;Does anyone have an idea on how I could go about this?&lt;/P&gt;&lt;P&gt;Thanks in advance &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2022 08:54:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/filter-data-based-on-most-recent-value-from/m-p/1218545#M6871</guid>
      <dc:creator>SineKelly17</dc:creator>
      <dc:date>2022-10-04T08:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: Filter data based on most recent value from different categories within layer</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/filter-data-based-on-most-recent-value-from/m-p/1218616#M6873</link>
      <description>&lt;P&gt;A data expression would be the way I'd do it. And I think we could do all the necessary work within a&amp;nbsp;&lt;STRONG&gt;GroupBy&lt;/STRONG&gt; statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var portal = Portal('your url')

var fs = FeatureSetByPortalItem(
    portal,
    'itemid',
    0, // or whatever layer index it is
    ['teamID', 'date_created'],
    false
)

return GroupBy(fs,
    'teamID',
    {
        name: 'latest_entry',
        expression: 'date_created',
        statistic: 'MAX'
    }
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mind that this expression would only be returning the latest date for each team ID. If you wanted to get the data values for those corresponding entries, you'd need to do a bit more work.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Oct 2022 13:56:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/filter-data-based-on-most-recent-value-from/m-p/1218616#M6873</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-10-04T13:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: Filter data based on most recent value from different categories within layer</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/filter-data-based-on-most-recent-value-from/m-p/1220628#M6883</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/472460"&gt;@Josh&lt;/a&gt;&amp;nbsp;this is along the lines of where I was going so helps to confirm that this should work!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I now have a script that technically does work, however it takes a long time for the table to load in the dashboard, due to the significant&lt;SPAN&gt;&amp;nbsp;overhead of functions used in the loop statement to get the top row on the date. The set of functions has to run for every unique teamID, so has a massive overhead.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I have attached an example of the code here, I don't know if you might be able to see a way to optimise this better?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Oct 2022 11:40:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/filter-data-based-on-most-recent-value-from/m-p/1220628#M6883</guid>
      <dc:creator>SineKelly17</dc:creator>
      <dc:date>2022-10-11T11:40:35Z</dc:date>
    </item>
  </channel>
</rss>

