<?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: timechart 'distinct_count' combined with 'latest' function in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/timechart-distinct-count-combined-with-latest-function/m-p/746981#M58760</link>
    <description>&lt;P&gt;Please try my updated query.&lt;/P&gt;</description>
    <pubDate>Tue, 27 May 2025 11:44:22 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2025-05-27T11:44:22Z</dc:date>
    <item>
      <title>timechart 'distinct_count' combined with 'latest' function</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/timechart-distinct-count-combined-with-latest-function/m-p/746912#M58753</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to create timechart that counts number of tests with different statuses (e.g. statuses 'OK', 'ERROR', 'WARN' etc) for last 30 days (per each day). The problem is that it should take only latest log with status per test (e.g. I have Login test (id 151), it has couple events/logs with different statuses, and I would like to take for that test last log/event with latest status.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a problem to combine 'latest' and 'distinct_count' with timechart.&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I do following search, I get duplicates of logs for test (e.g. I should have every day count of 62 (tests) for all statuses):&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;basesearch
| timechart span=1d distinct_count(test) as tests by status&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="chrome_zQzO00MHWQ.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/39145i3B444C0897B9602F/image-size/large?v=v2&amp;amp;px=999" role="button" title="chrome_zQzO00MHWQ.png" alt="chrome_zQzO00MHWQ.png" /&gt;&lt;/span&gt;e.g. on day 2025-05-26 test 'Login test (id 151)' have one event with status 'OK' and another one with status 'Blad', and the duplicate is shown here.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;When I want to combine 'latest' to timechart I get distinct_count results only for last day:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;basesearch
| stats latest(status) as statuses latest(test) as tests latest(_time) as myTime by test
| eval _time=myTime 
| timechart span=1d distinct_count(tests) by statuses&lt;/LI-CODE&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="chrome_m3MOr3Gn1e.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/39146i76B04FD36E243E96/image-size/large?v=v2&amp;amp;px=999" role="button" title="chrome_m3MOr3Gn1e.png" alt="chrome_m3MOr3Gn1e.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I appreciate help how to combine timechart, distinct_count and latest all together.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 May 2025 11:15:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/timechart-distinct-count-combined-with-latest-function/m-p/746912#M58753</guid>
      <dc:creator>jbllog</dc:creator>
      <dc:date>2025-05-26T11:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: timechart 'distinct_count' combined with 'latest' function</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/timechart-distinct-count-combined-with-latest-function/m-p/746923#M58755</link>
      <description>&lt;P&gt;You almost had it.&amp;nbsp; Use the &lt;FONT face="courier new,courier"&gt;bin&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;stats&lt;/FONT&gt; commands to group events by day and get the latest status.&amp;nbsp; Then &lt;FONT face="courier new,courier"&gt;timechart&lt;/FONT&gt; will give the counts.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;basesearch
| bin span=1d _time
| stats latest(status) as status by _time, test
| timechart span=1d distinct_count(test) by status&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 May 2025 11:44:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/timechart-distinct-count-combined-with-latest-function/m-p/746923#M58755</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2025-05-27T11:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: timechart 'distinct_count' combined with 'latest' function</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/timechart-distinct-count-combined-with-latest-function/m-p/746951#M58759</link>
      <description>&lt;P&gt;Thank you for the response &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I tried your solution but still have results only for one day.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="chrome_iUgbbE3R24.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/39152iE8E463EB5F019F1F/image-size/large?v=v2&amp;amp;px=999" role="button" title="chrome_iUgbbE3R24.png" alt="chrome_iUgbbE3R24.png" /&gt;&lt;/span&gt;&lt;BR /&gt;I wonder maybe this line may affect the unwanted one-day results:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;status latest(test) as tests latest(_time) as _time&lt;/PRE&gt;&lt;P&gt;maybe I shouldn't use 'latest' agg function for 'test' and '_time'? But I don't know how to pass these values in a different way to 'timechart' function.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 May 2025 11:05:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/timechart-distinct-count-combined-with-latest-function/m-p/746951#M58759</guid>
      <dc:creator>jbllog</dc:creator>
      <dc:date>2025-05-27T11:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: timechart 'distinct_count' combined with 'latest' function</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/timechart-distinct-count-combined-with-latest-function/m-p/746981#M58760</link>
      <description>&lt;P&gt;Please try my updated query.&lt;/P&gt;</description>
      <pubDate>Tue, 27 May 2025 11:44:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/timechart-distinct-count-combined-with-latest-function/m-p/746981#M58760</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2025-05-27T11:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: timechart 'distinct_count' combined with 'latest' function</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/timechart-distinct-count-combined-with-latest-function/m-p/746982#M58761</link>
      <description>&lt;P&gt;It works! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Thank you for the solution :)!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 May 2025 12:33:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/timechart-distinct-count-combined-with-latest-function/m-p/746982#M58761</guid>
      <dc:creator>jbllog</dc:creator>
      <dc:date>2025-05-27T12:33:21Z</dc:date>
    </item>
  </channel>
</rss>

