<?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: Count distinct SPL help in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Count-distinct-SPL-help/m-p/527498#M148904</link>
    <description>&lt;P&gt;Great ideal ITWhisperer,&lt;BR /&gt;It is exactly what i am looking for. I am developing a sum count between date, but your solution is straightforward and much better. Hope to see you arround very soon&lt;/P&gt;</description>
    <pubDate>Mon, 02 Nov 2020 10:51:21 GMT</pubDate>
    <dc:creator>thuhuongle</dc:creator>
    <dc:date>2020-11-02T10:51:21Z</dc:date>
    <item>
      <title>Count distinct SPL help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-distinct-SPL-help/m-p/527316#M148859</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;BR /&gt;Looking forward to learn from you guys. I am stucked at this calculation: Total of product in contract.&lt;BR /&gt;I made a simple dataset to simplify my data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval date = "2017-01-30" , source = "a", id="111"
| makemv delim="," id
| makemv delim="," date
| makemv delim="," source
| append 
    [| makeresults 
| eval date = "2017-01-30" , source = "b", id="222"
| makemv delim="," id
| makemv delim="," date
| makemv delim="," source]
| append 
    [| makeresults 
| eval date = "2019-08-20" , source = "a", id="333"
| makemv delim="," id
| makemv delim="," date
| makemv delim="," source]
| append 
    [| makeresults 
| eval date = "2020-01-20" , source = "a", id="444"
| makemv delim="," id
| makemv delim="," date
| makemv delim="," source]
| append 
    [| makeresults 
| eval date = "2020-03-20" , source = "b", id="555"
| makemv delim="," id
| makemv delim="," date
| makemv delim="," source]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;INPUT: let's image _time is date time of buying record&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;_time&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;signed contract date&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;id&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;source&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;2020-10-30 14:55:55&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;2017-01-30&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;111&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;a&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;2020-10-30 14:55:55&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;2017-01-30&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;222&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;b&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;2020-08-30 14:55:55&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;2019-08-20&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;333&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;a&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;2020-01-30 14:55:55&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;2020-01-20&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;444&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;a&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;2020-09-30 14:55:55&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;&amp;nbsp;2020-03-20&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;555&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;b&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;The expected output: Count total product in contract from 12/2019 to 03/2020&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;Time&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;total_nb_product&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;Source&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;12/2019&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;2&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;a&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;12/2019&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;1&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;b&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;01/2020&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;3&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;a&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;01/2020&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;1&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;b&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;02/2020&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;3&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;a&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;02/2020&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;1&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;b&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;03/2020&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;3&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;a&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;03/2020&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;2&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="25px"&gt;b&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Thank for your time and hope to received your suggestion.&amp;nbsp;&lt;BR /&gt;Great weekend&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2020 14:03:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-distinct-SPL-help/m-p/527316#M148859</guid>
      <dc:creator>thuhuongle</dc:creator>
      <dc:date>2020-10-30T14:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: Count distinct SPL help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-distinct-SPL-help/m-p/527339#M148864</link>
      <description>&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval date = "2017-01-30" , source = "a", id="111"
| makemv delim="," id
| makemv delim="," date
| makemv delim="," source
| append 
    [| makeresults 
| eval date = "2017-01-30" , source = "b", id="222"
| makemv delim="," id
| makemv delim="," date
| makemv delim="," source]
| append 
    [| makeresults 
| eval date = "2019-08-20" , source = "a", id="333"
| makemv delim="," id
| makemv delim="," date
| makemv delim="," source]
| append 
    [| makeresults 
| eval date = "2020-01-20" , source = "a", id="444"
| makemv delim="," id
| makemv delim="," date
| makemv delim="," source]
| append 
    [| makeresults 
| eval date = "2020-03-20" , source = "b", id="555"
| makemv delim="," id
| makemv delim="," date
| makemv delim="," source]
| eval Time=round(relative_time(strptime(date,"%Y-%m-%d"),"@mon"))
| makecontinuous Time span=1mon
| fields - _time date
| eventstats values(source) as sources
| mvexpand sources
| eval source=coalesce(source, sources)
| eval id=if(source=sources,id,null)
| fields - source
| rename sources as Source
| stats values(id) as id by Time Source
| streamstats count(id) as total_nb_product by Source
| fields Time total_nb_product Source
| fieldformat Time=strftime(Time,"%m/%Y")&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 30 Oct 2020 16:44:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-distinct-SPL-help/m-p/527339#M148864</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2020-10-30T16:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: Count distinct SPL help</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Count-distinct-SPL-help/m-p/527498#M148904</link>
      <description>&lt;P&gt;Great ideal ITWhisperer,&lt;BR /&gt;It is exactly what i am looking for. I am developing a sum count between date, but your solution is straightforward and much better. Hope to see you arround very soon&lt;/P&gt;</description>
      <pubDate>Mon, 02 Nov 2020 10:51:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Count-distinct-SPL-help/m-p/527498#M148904</guid>
      <dc:creator>thuhuongle</dc:creator>
      <dc:date>2020-11-02T10:51:21Z</dc:date>
    </item>
  </channel>
</rss>

