<?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 can I group last results into OTHERS? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420434#M167182</link>
    <description>&lt;P&gt;I tried it but in the result it shows only the first 5 rows..&lt;/P&gt;

&lt;H1&gt;"Country" "Sales" "Total Sales" "Percentage" &lt;/H1&gt;

&lt;P&gt;A 300 1855 16.5&lt;BR /&gt;
B 250 1855 13.2&lt;BR /&gt;
C 200 1855 10.9&lt;BR /&gt;
D 190 1855 10.2&lt;BR /&gt;
E 180 1855 9.7&lt;/P&gt;</description>
    <pubDate>Tue, 09 Oct 2018 20:53:25 GMT</pubDate>
    <dc:creator>anoopk1981</dc:creator>
    <dc:date>2018-10-09T20:53:25Z</dc:date>
    <item>
      <title>How can I group last results into OTHERS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420431#M167179</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a search that gives me results as below &lt;/P&gt;

&lt;H1&gt;"Country"   "Sales"       "Total Sales"   "Percentage"     &lt;/H1&gt;

&lt;PRE&gt;&lt;CODE&gt; A                  300         1855           16.5
 B                  250         1855           13.2
 C                  200         1855           10.9
 D          190         1855           10.2
 E                  180         1855            9.7
 F                  160         1855            8.6
 G          155         1855            8.3
 H          145         1855            7.8
 I                   140    1855            7.5
 J                   135    1855            7.2 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now I want to show only the first 5 rows and group the remaining rows into Others..something as below&lt;/P&gt;

&lt;H1&gt;"Country"   "Sales"       "Total Sales"   "Percentage"     &lt;/H1&gt;

&lt;PRE&gt;&lt;CODE&gt; A                  300         1855           16.5
 B                  250         1855           13.2
 C                  200         1855           10.9
 D          190         1855           10.2
 E                  180         1855            9.7
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OTHERS         735         1855              39.6&lt;/P&gt;

&lt;P&gt;Thank You &lt;/P&gt;</description>
      <pubDate>Mon, 08 Oct 2018 21:46:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420431#M167179</guid>
      <dc:creator>anoopk1981</dc:creator>
      <dc:date>2018-10-08T21:46:19Z</dc:date>
    </item>
    <item>
      <title>Re: How can I group last results into OTHERS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420432#M167180</link>
      <description>&lt;P&gt;Here's one way ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your search
| sort 0 - Percentage
| streamstats count as recno
| appendpipe 
    [ | where recno &amp;gt; 5 
      | stats sum(Sales) as Sales sum(Percentage) as Percentage by "Total Sales" 
      | eval Country = "OTHER" 
      | eval recno=5.5 
     ]
| where recno &amp;lt;6
| fields - recno
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Oct 2018 02:58:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420432#M167180</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-10-09T02:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: How can I group last results into OTHERS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420433#M167181</link>
      <description>&lt;P&gt;Thank You. &lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 20:44:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420433#M167181</guid>
      <dc:creator>anoopk1981</dc:creator>
      <dc:date>2018-10-09T20:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: How can I group last results into OTHERS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420434#M167182</link>
      <description>&lt;P&gt;I tried it but in the result it shows only the first 5 rows..&lt;/P&gt;

&lt;H1&gt;"Country" "Sales" "Total Sales" "Percentage" &lt;/H1&gt;

&lt;P&gt;A 300 1855 16.5&lt;BR /&gt;
B 250 1855 13.2&lt;BR /&gt;
C 200 1855 10.9&lt;BR /&gt;
D 190 1855 10.2&lt;BR /&gt;
E 180 1855 9.7&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 20:53:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420434#M167182</guid>
      <dc:creator>anoopk1981</dc:creator>
      <dc:date>2018-10-09T20:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: How can I group last results into OTHERS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420435#M167183</link>
      <description>&lt;P&gt;You can use at the end of your query- &lt;CODE&gt;|top limit=10 Percentage  useother=1&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 21:07:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420435#M167183</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2018-10-09T21:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: How can I group last results into OTHERS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420436#M167184</link>
      <description>&lt;P&gt;hi @anoopk1981&lt;/P&gt;

&lt;P&gt;Did the answer below solve your problem? If so, please resolve this post by approving it! &lt;BR /&gt;
If your problem is still not solved, keep us updated so that someone else can help ya. Thanks for posting!&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 22:43:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420436#M167184</guid>
      <dc:creator>mstjohn_splunk</dc:creator>
      <dc:date>2018-10-09T22:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: How can I group last results into OTHERS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420437#M167185</link>
      <description>&lt;P&gt;top won't work. top gives me the values by the most number of occurrences . This is entirely different . &lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 23:48:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420437#M167185</guid>
      <dc:creator>anoopk1981</dc:creator>
      <dc:date>2018-10-09T23:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: How can I group last results into OTHERS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420438#M167186</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;P&gt;your search&lt;BR /&gt;
| sort 0 - Percentage&lt;BR /&gt;
|streamstats count as c&lt;BR /&gt;
| eval Country=if(c&amp;gt;5,"Other",Country)&lt;BR /&gt;
| stats sum(Sales) as Sales sum(Percentage) as Percentage sum("Total Sales") as "Total Sales"  by Country&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 01:59:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420438#M167186</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2018-10-10T01:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: How can I group last results into OTHERS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420439#M167187</link>
      <description>&lt;P&gt;Put  an eval like this before the transform command that gives you the Sales by Country:&lt;/P&gt;

&lt;P&gt;eval Country = case(Country=="A","A",Country=="B","B",Country=="C","C",Country=="D","D",Country=="E","E",true(),"Others")&lt;/P&gt;

&lt;P&gt;for example:&lt;/P&gt;

&lt;P&gt;index="myindex"&lt;BR /&gt;
| eval Country = case(Country=="A","A",Country=="B","B",Country=="C","C",Country=="D","D",Country=="E","E",true(),"Others") &lt;BR /&gt;
| stats count as Sales by Country&lt;BR /&gt;
| eventstats  sum(Sales) as TotalSales&lt;BR /&gt;
| eval Percentage = Sales / TotalSales&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 02:18:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420439#M167187</guid>
      <dc:creator>dstile</dc:creator>
      <dc:date>2018-10-10T02:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: How can I group last results into OTHERS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420440#M167188</link>
      <description>&lt;P&gt;This is my main search&lt;/P&gt;

&lt;P&gt;index = "myindex" | eventstats sum("Declared Value _USD") as total_sales |stats sum("Declared Value _USD") as sales max(total_sales) as total_sales by "Destination Country Correct Translation"|eval Percentage=sales/total_sales*100 |sort 0 - sales&lt;/P&gt;

&lt;P&gt;So where do you suggest to put your statements?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:35:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420440#M167188</guid>
      <dc:creator>anoopk1981</dc:creator>
      <dc:date>2020-09-29T21:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: How can I group last results into OTHERS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420441#M167189</link>
      <description>&lt;P&gt;It gave me only the Other row..not the first five rows + Other . &lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 19:08:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420441#M167189</guid>
      <dc:creator>anoopk1981</dc:creator>
      <dc:date>2018-10-10T19:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: How can I group last results into OTHERS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420442#M167190</link>
      <description>&lt;P&gt;Please check the value of c generated using streamstats. The value should be 1,2,3,4,5,6,....&lt;BR /&gt;
Also please make sure the fieldname from your query is same as the fieldname used for Country . It will be helpful if you can paste your code here.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 19:15:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420442#M167190</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2018-10-10T19:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: How can I group last results into OTHERS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420443#M167191</link>
      <description>&lt;P&gt;index = "myindex" &lt;BR /&gt;
| eval "Destination Country Correct Translation" = case("Destination Country Correct Translation"=="A","A","Destination Country Correct Translation"=="B","B","Destination Country Correct Translation"=="C","C","Destination Country Correct Translation"=="D","D","Destination Country Correct Translation"=="E","E",true(),"Others")&lt;BR /&gt;
| stats sum("Declared Value _USD") as sales by "Destination Country Correct Translation"&lt;BR /&gt;
| eventstats sum(sales) as total_sales&lt;BR /&gt;
| eval Percentage=sales/total_sales*100&lt;BR /&gt;
| sort 0 - sales&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:32:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420443#M167191</guid>
      <dc:creator>dstile</dc:creator>
      <dc:date>2020-09-29T21:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: How can I group last results into OTHERS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420444#M167192</link>
      <description>&lt;P&gt;You need to add this command after your query and before streamstats&lt;/P&gt;

&lt;P&gt;|rename “Destination Country Correct Translation" as Country &lt;/P&gt;</description>
      <pubDate>Thu, 11 Oct 2018 02:30:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420444#M167192</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2018-10-11T02:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: How can I group last results into OTHERS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420445#M167193</link>
      <description>&lt;P&gt;I tried but got this result&lt;/P&gt;

&lt;P&gt;Destination Country Correct Translation  sales  Percentage  total_sales&lt;BR /&gt;
Others                                                           1855   100                 1855&lt;/P&gt;</description>
      <pubDate>Thu, 11 Oct 2018 19:20:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420445#M167193</guid>
      <dc:creator>anoopk1981</dc:creator>
      <dc:date>2018-10-11T19:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: How can I group last results into OTHERS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420446#M167194</link>
      <description>&lt;P&gt;This is my current query..&lt;/P&gt;

&lt;P&gt;index="marketing1" sourcetype="csv" | eventstats sum("Declared Value _USD") as total_sales |stats sum("Declared Value _USD") as sales max(total_sales) as total_sales by "Destination Country Correct Translation"|eval Percentage=sales/total_sales*100 |sort 0 - sales&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:36:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420446#M167194</guid>
      <dc:creator>anoopk1981</dc:creator>
      <dc:date>2020-09-29T21:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: How can I group last results into OTHERS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420447#M167195</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;P&gt;index="marketing1" sourcetype="csv" | eventstats sum("Declared Value _USD") as total_sales |stats sum("Declared Value _USD") as sales max(total_sales) as total_sales by "Destination Country Correct Translation"|eval Percentage=sales/total_sales*100 |sort 0 - sales| rename "Destination Country Correct Translation" as Country&lt;/P&gt;

&lt;P&gt;| sort 0 - Percentage&lt;BR /&gt;
|streamstats count as c&lt;BR /&gt;
| eval Country=if(c&amp;gt;5,"Other",Country)&lt;BR /&gt;
| stats sum(sales) as Sales sum(Percentage) as Percentage max("total_sales") as "Total Sales" by Country&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:33:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420447#M167195</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2020-09-29T21:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: How can I group last results into OTHERS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420448#M167196</link>
      <description>&lt;P&gt;Yes. That worked. Than You&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2018 16:32:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420448#M167196</guid>
      <dc:creator>anoopk1981</dc:creator>
      <dc:date>2018-10-12T16:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: How can I group last results into OTHERS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420449#M167197</link>
      <description>&lt;P&gt;Please accept the answer if that worked for you. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Oct 2018 16:48:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420449#M167197</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2018-10-12T16:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: How can I group last results into OTHERS?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420450#M167198</link>
      <description>&lt;P&gt;I think you got bit by an issue Splunk has with using fields that include spaces in evals. A rename of the Destination Country Correct Translation to a field name with no spaces would have sorted it.&lt;/P&gt;

&lt;P&gt;index = "myindex" &lt;BR /&gt;
| rename "Destination Country Correct Translation" as Country&lt;BR /&gt;
| eval Country = case(Country=="A","A",Country=="B","B",Country=="C","C",Country=="D","D",Country=="E","E",true(),"Others")&lt;BR /&gt;
| stats sum("Declared Value _USD") as sales by Country&lt;BR /&gt;
| eventstats sum(sales) as total_sales&lt;BR /&gt;
| eval Percentage=sales/total_sales*100&lt;BR /&gt;
| sort 0 - sales&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:40:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-group-last-results-into-OTHERS/m-p/420450#M167198</guid>
      <dc:creator>dstile</dc:creator>
      <dc:date>2020-09-29T21:40:56Z</dc:date>
    </item>
  </channel>
</rss>

