<?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: How to form a search based on my data and my desired output? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-form-a-search-based-on-my-data-and-my-desired-output/m-p/204942#M59550</link>
    <description>&lt;P&gt;Give this a try if you want to count based on the month and how many times it occurred:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query to return the data as given in question
| rex field=Name "\-(?&amp;lt;month&amp;gt;.*)"
| stats count by month
| rename month as Name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Updating as per info given in comments&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query to return the data as given in question
| rex field=Name "\-(?&amp;lt;Name&amp;gt;.*)"
| streamstats dc(Value) as Value
| stats last(Value) by Name
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 22 Dec 2016 06:35:32 GMT</pubDate>
    <dc:creator>gokadroid</dc:creator>
    <dc:date>2016-12-22T06:35:32Z</dc:date>
    <item>
      <title>How to form a search based on my data and my desired output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-form-a-search-based-on-my-data-and-my-desired-output/m-p/204940#M59548</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;I have the below format of data &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Name    Value
1-Jan   A
2-Jan   B
2-Jan   B
3-Jan   C
2-Feb    A
1-Mar   V
2-Mar   B
3-Mar   C
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Output needs to be like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Name    Value
Jan   3
FEB   3
Mar      4
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please help me format the search.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2016 05:49:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-form-a-search-based-on-my-data-and-my-desired-output/m-p/204940#M59548</guid>
      <dc:creator>rsathish47</dc:creator>
      <dc:date>2016-12-22T05:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to form a search based on my data and my desired output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-form-a-search-based-on-my-data-and-my-desired-output/m-p/204941#M59549</link>
      <description>&lt;P&gt;Try this (assuming format of field Name is %d-%b , date-month AND you want to count how many distinct values of field 'Value' is available in the month)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your current search giving field Name, Value
| eval Name=mvindex(split(Name,"-")-1) 
| stats dc(Value) as Value by Name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If this is not what you want, please provide more details on your requirement/data.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2016 05:54:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-form-a-search-based-on-my-data-and-my-desired-output/m-p/204941#M59549</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-12-22T05:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to form a search based on my data and my desired output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-form-a-search-based-on-my-data-and-my-desired-output/m-p/204942#M59550</link>
      <description>&lt;P&gt;Give this a try if you want to count based on the month and how many times it occurred:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query to return the data as given in question
| rex field=Name "\-(?&amp;lt;month&amp;gt;.*)"
| stats count by month
| rename month as Name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Updating as per info given in comments&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query to return the data as given in question
| rex field=Name "\-(?&amp;lt;Name&amp;gt;.*)"
| streamstats dc(Value) as Value
| stats last(Value) by Name
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Dec 2016 06:35:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-form-a-search-based-on-my-data-and-my-desired-output/m-p/204942#M59550</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-12-22T06:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to form a search based on my data and my desired output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-form-a-search-based-on-my-data-and-my-desired-output/m-p/204943#M59551</link>
      <description>&lt;P&gt;Thank You for the query&lt;BR /&gt;
I got below output but it is not correct output&lt;BR /&gt;
Name    Value&lt;BR /&gt;
Feb     1&lt;BR /&gt;
Jan     3&lt;BR /&gt;
Mar     3&lt;/P&gt;

&lt;P&gt;i want dedup month &lt;BR /&gt;
Jan --&amp;gt; dedup till Jan --&amp;gt; 3&lt;BR /&gt;
FEB --&amp;gt; dedup till Feb---&amp;gt; 3&lt;BR /&gt;
Mar--&amp;gt; dedup till Mar---&amp;gt; 4&lt;BR /&gt;
...&lt;BR /&gt;
Please help me &lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2016 06:46:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-form-a-search-based-on-my-data-and-my-desired-output/m-p/204943#M59551</guid>
      <dc:creator>rsathish47</dc:creator>
      <dc:date>2016-12-22T06:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to form a search based on my data and my desired output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-form-a-search-based-on-my-data-and-my-desired-output/m-p/204944#M59552</link>
      <description>&lt;P&gt;I tried it but it is not giving right count.&lt;/P&gt;

&lt;P&gt;i want dedup month &lt;BR /&gt;
Jan --&amp;gt; dedup till Jan --&amp;gt; 3&lt;BR /&gt;
FEB --&amp;gt; dedup till Feb---&amp;gt; 3&lt;BR /&gt;
Mar--&amp;gt; dedup till Mar---&amp;gt; 4&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2016 07:23:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-form-a-search-based-on-my-data-and-my-desired-output/m-p/204944#M59552</guid>
      <dc:creator>rsathish47</dc:creator>
      <dc:date>2016-12-22T07:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to form a search based on my data and my desired output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-form-a-search-based-on-my-data-and-my-desired-output/m-p/204945#M59553</link>
      <description>&lt;P&gt;What are your exact requirements? I get you're deduping but what are you doing exactly (more details)?&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2016 07:39:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-form-a-search-based-on-my-data-and-my-desired-output/m-p/204945#M59553</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-12-22T07:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to form a search based on my data and my desired output?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-form-a-search-based-on-my-data-and-my-desired-output/m-p/204946#M59554</link>
      <description>&lt;P&gt;This one was fun (mostly because I enjoyed the brain-teaser of figuring out what exactly you were doing to get the shown outcome):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults | eval raw="1-Jan    A::2-Jan    B::2-Jan    B::3-Jan    C::2-Feb    A::1-Mar    V::2-Mar    B::3-Mar    C"
| makemv delim="::" raw
| mvexpand raw
| rename raw AS _raw
| rex "(?&amp;lt;Name&amp;gt;\S+)\s+(?&amp;lt;Value&amp;gt;.*)"
| fields - _raw _time

| rename COMMENT AS "Everything above is faking the data; Everthing below is your solution"

| rex field=Name mode=sed "s/^\d+\-//"
| eval Name=strftime(strptime(Name . " 1 2017", "%b %d %Y"), "%m")
| sort 0 Name
| stats values(Value) AS Value BY Name
| streamstats values(Value) AS Value
| stats dc(Value) AS Value BY Name
| fieldformat Name=strftime(strptime(Name . " 1 2017", "%m %d %Y"), "%b")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 25 Mar 2017 06:41:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-form-a-search-based-on-my-data-and-my-desired-output/m-p/204946#M59554</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-25T06:41:07Z</dc:date>
    </item>
  </channel>
</rss>

