<?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: Dashboard List Widget - Find Distinct $datapoints in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/dashboard-list-widget-find-distinct-datapoints/m-p/1369768#M6902</link>
    <description>&lt;P&gt;You can find a bunch of examples here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcade-expressions/tree/master/dashboard_data" target="_blank"&gt;https://github.com/Esri/arcade-expressions/tree/master/dashboard_data&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Your particular case is easy enough, since the requirement is to remove duplicates. There is an Arcade function &lt;STRONG&gt;Distinct&lt;/STRONG&gt;, which returns a FeatureSet.&lt;/P&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSetByPortalItem(
  Portal('your portal url'),
  'itemid of the service',
  0,
  ['fields', 'you', 'want'],
  false
)

return Distinct(
  fs,
  ['fields', 'you', 'want']
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Jan 2024 19:58:33 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2024-01-12T19:58:33Z</dc:date>
    <item>
      <title>Dashboard List Widget - Find Distinct $datapoints</title>
      <link>https://community.esri.com/t5/developers-questions/dashboard-list-widget-find-distinct-datapoints/m-p/1369703#M6899</link>
      <description>&lt;P&gt;I am looking for some help regarding an Arcade script that I am developing for the ESRI Dashboard List Widget. Essentially, I have a hosted feature table that has duplicate records based on "unique_user" but must remain split due to some non-duplicate attributes. I would like to only display only one DISTINCT record, based on "unique_user." As long as the script only returns one $datapoint then that is fine - the index does not matter.&lt;/P&gt;&lt;P&gt;Here is what I have so far, any thoughts on how to only return one distinct value per "unique_user"?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// different categories of days anticipated
var perm_status = $datapoint["perm_status"]
var dateTechReviewComplete = Date($datapoint["dt_tech_review_complete"])

// extra variables
var dateSubmitted = Date($datapoint["dt_submitted"])
var nowDate = Date(Now())

if (perm_status == "Technical Review Complete") {
    var tech = DateAdd(dateTechReviewComplete, 195, 'days')
    var daysAnt = Text(tech, "MMMM D, Y")
    var dateDifference = Round(DateDiff(tech, nowDate, 'days'))
    // Return only one DISTINCT date based upon "unique_user"
}
else {
    var daysAnt = "No Permit Status Reported"
    return True
}

return {
  textColor: '',
  backgroundColor: '',
  separatorColor:'',
  selectionColor: '',
  selectionTextColor: '',
  attributes: {
    daysAnticipated: daysAnt,
    permitStatus: perm_status,
    daysDifference: dateDifference
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what the code currently returns, duplicates have a red mark next to them:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="moremeowbell_0-1705081744669.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/91458i380D1D7EBE99F4EF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="moremeowbell_0-1705081744669.png" alt="moremeowbell_0-1705081744669.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The desired result is that only one of the duplicate rows is returned.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 17:51:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/dashboard-list-widget-find-distinct-datapoints/m-p/1369703#M6899</guid>
      <dc:creator>moremeowbell</dc:creator>
      <dc:date>2024-01-12T17:51:53Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard List Widget - Find Distinct $datapoints</title>
      <link>https://community.esri.com/t5/developers-questions/dashboard-list-widget-find-distinct-datapoints/m-p/1369722#M6900</link>
      <description>&lt;P&gt;To get distinct values, you need to either:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Write a Data Expression that filters them out, or&lt;/LI&gt;&lt;LI&gt;Use a Table widget, which has built-in grouping&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;In the Advanced Formatting part of the widget, your Arcade expression can only evaluate per-row, and it can't "see" other features in the layer.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 18:13:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/dashboard-list-widget-find-distinct-datapoints/m-p/1369722#M6900</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2024-01-12T18:13:45Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard List Widget - Find Distinct $datapoints</title>
      <link>https://community.esri.com/t5/developers-questions/dashboard-list-widget-find-distinct-datapoints/m-p/1369762#M6901</link>
      <description>&lt;P&gt;Thanks! Do you know how I would write a data expression to filter?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 19:32:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/dashboard-list-widget-find-distinct-datapoints/m-p/1369762#M6901</guid>
      <dc:creator>moremeowbell</dc:creator>
      <dc:date>2024-01-12T19:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard List Widget - Find Distinct $datapoints</title>
      <link>https://community.esri.com/t5/developers-questions/dashboard-list-widget-find-distinct-datapoints/m-p/1369768#M6902</link>
      <description>&lt;P&gt;You can find a bunch of examples here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcade-expressions/tree/master/dashboard_data" target="_blank"&gt;https://github.com/Esri/arcade-expressions/tree/master/dashboard_data&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Your particular case is easy enough, since the requirement is to remove duplicates. There is an Arcade function &lt;STRONG&gt;Distinct&lt;/STRONG&gt;, which returns a FeatureSet.&lt;/P&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSetByPortalItem(
  Portal('your portal url'),
  'itemid of the service',
  0,
  ['fields', 'you', 'want'],
  false
)

return Distinct(
  fs,
  ['fields', 'you', 'want']
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 19:58:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/dashboard-list-widget-find-distinct-datapoints/m-p/1369768#M6902</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2024-01-12T19:58:33Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard List Widget - Find Distinct $datapoints</title>
      <link>https://community.esri.com/t5/developers-questions/dashboard-list-widget-find-distinct-datapoints/m-p/1370457#M6904</link>
      <description>&lt;P&gt;Thanks for the link, really helpful!&amp;nbsp;&lt;/P&gt;&lt;P&gt;When attempting to return Distinct values, I am getting this Console error. We only have Enterprise 10.9.1 - do you think that may be a reason the analysis isn't supported?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="moremeowbell_0-1705413571302.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/91688i52CD3010FD0688D2/image-size/large?v=v2&amp;amp;px=999" role="button" title="moremeowbell_0-1705413571302.png" alt="moremeowbell_0-1705413571302.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2024 13:59:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/dashboard-list-widget-find-distinct-datapoints/m-p/1370457#M6904</guid>
      <dc:creator>moremeowbell</dc:creator>
      <dc:date>2024-01-16T13:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: Dashboard List Widget - Find Distinct $datapoints</title>
      <link>https://community.esri.com/t5/developers-questions/dashboard-list-widget-find-distinct-datapoints/m-p/1370476#M6905</link>
      <description>&lt;P&gt;What you're seeing is a result of&amp;nbsp; the particular &lt;STRONG&gt;Profile&lt;/STRONG&gt; you're using.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/arcade/profiles/" target="_blank"&gt;https://developers.arcgis.com/arcade/profiles/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;In the Advanced Formatting, you cannot use FeatureSet functions. To use a Data Expression, you've actually got to go all the way back to where you choose a data layer for the widget, then say "New Data Expression" there.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2024 14:59:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/dashboard-list-widget-find-distinct-datapoints/m-p/1370476#M6905</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2024-01-16T14:59:56Z</dc:date>
    </item>
  </channel>
</rss>

