<?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 How to limit results in a bar chart while still sorting by one of the values of column-split field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-limit-results-in-a-bar-chart-while-still-sorting-by-one/m-p/497121#M138472</link>
    <description>&lt;P&gt;I have this search, where I am charting usage over &lt;CODE&gt;id&lt;/CODE&gt; field (which is on x-axis)  split by two columns - two values of &lt;CODE&gt;Day&lt;/CODE&gt; field.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=foo resource=foobar
earliest=-1d@d latest=now
| eval Day=if(_time&amp;lt;relative_time(now(),"@d"),"Yesterday","Today")
| rex max_match=0 "(?:'id': )(?P&amp;lt;id&amp;gt;[^,]+)|(?:'usage': )(?P&amp;lt;usage&amp;gt;[^,]+)" 
| chart latest(usage) over id by Day 
| where Yesterday!=Today | table id Yesterday Today | sort Today
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there a way to limit the result to a certain number? &lt;BR /&gt;
I tried &lt;CODE&gt;| sort 5 Today&lt;/CODE&gt; .&lt;BR /&gt;&lt;BR /&gt;
&lt;CODE&gt;| sort Today&lt;/CODE&gt; breaks when I add a limit - as if it stops sorting by &lt;CODE&gt;Today&lt;/CODE&gt; and starts sorting by &lt;CODE&gt;id&lt;/CODE&gt;.&lt;BR /&gt;
When I use &lt;CODE&gt;sort 5 Now&lt;/CODE&gt; it results in sorting by &lt;CODE&gt;id&lt;/CODE&gt; while I actually want to sort by &lt;CODE&gt;usage&lt;/CODE&gt; in &lt;CODE&gt;Today&lt;/CODE&gt; column. Is that possible?&lt;BR /&gt;&lt;BR /&gt;
Thank you.&lt;/P&gt;</description>
    <pubDate>Tue, 17 Mar 2020 19:44:19 GMT</pubDate>
    <dc:creator>nickrally2009</dc:creator>
    <dc:date>2020-03-17T19:44:19Z</dc:date>
    <item>
      <title>How to limit results in a bar chart while still sorting by one of the values of column-split field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-limit-results-in-a-bar-chart-while-still-sorting-by-one/m-p/497121#M138472</link>
      <description>&lt;P&gt;I have this search, where I am charting usage over &lt;CODE&gt;id&lt;/CODE&gt; field (which is on x-axis)  split by two columns - two values of &lt;CODE&gt;Day&lt;/CODE&gt; field.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=foo resource=foobar
earliest=-1d@d latest=now
| eval Day=if(_time&amp;lt;relative_time(now(),"@d"),"Yesterday","Today")
| rex max_match=0 "(?:'id': )(?P&amp;lt;id&amp;gt;[^,]+)|(?:'usage': )(?P&amp;lt;usage&amp;gt;[^,]+)" 
| chart latest(usage) over id by Day 
| where Yesterday!=Today | table id Yesterday Today | sort Today
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there a way to limit the result to a certain number? &lt;BR /&gt;
I tried &lt;CODE&gt;| sort 5 Today&lt;/CODE&gt; .&lt;BR /&gt;&lt;BR /&gt;
&lt;CODE&gt;| sort Today&lt;/CODE&gt; breaks when I add a limit - as if it stops sorting by &lt;CODE&gt;Today&lt;/CODE&gt; and starts sorting by &lt;CODE&gt;id&lt;/CODE&gt;.&lt;BR /&gt;
When I use &lt;CODE&gt;sort 5 Now&lt;/CODE&gt; it results in sorting by &lt;CODE&gt;id&lt;/CODE&gt; while I actually want to sort by &lt;CODE&gt;usage&lt;/CODE&gt; in &lt;CODE&gt;Today&lt;/CODE&gt; column. Is that possible?&lt;BR /&gt;&lt;BR /&gt;
Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2020 19:44:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-limit-results-in-a-bar-chart-while-still-sorting-by-one/m-p/497121#M138472</guid>
      <dc:creator>nickrally2009</dc:creator>
      <dc:date>2020-03-17T19:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to limit results in a bar chart while still sorting by one of the values of column-split field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-limit-results-in-a-bar-chart-while-still-sorting-by-one/m-p/497122#M138473</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;source=foo resource=foobar
earliest=-1d@d latest=now
| eval Day=if(_time&amp;lt;relative_time(now(),"@d"),"Yesterday","Today")
| rex max_match=0 "(?:'id': )(?P&amp;lt;id&amp;gt;[^,]+)|(?:'usage': )(?P&amp;lt;usage&amp;gt;[^,]+)" 
| chart latest(usage) over id by Day 
| streamstats count(eval(Yesterday!=Today)) as session
| where Yesterday!=Today AND session &amp;lt; 6
| table id Yesterday Today 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;see &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Chart"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Chart&lt;/A&gt;&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;limit

&lt;UL&gt;
&lt;LI&gt;Syntax: limit=&lt;/LI&gt;
&lt;LI&gt;Description: Only valid when a column-split is specified. Use the limit option to specify the number of results that should appear in the output. When you set limit=N the top N values are retained, based on the sum of each series. If limit=0, all results are returned.&lt;/LI&gt;
&lt;/UL&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Tue, 17 Mar 2020 19:57:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-limit-results-in-a-bar-chart-while-still-sorting-by-one/m-p/497122#M138473</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-03-17T19:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to limit results in a bar chart while still sorting by one of the values of column-split field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-limit-results-in-a-bar-chart-while-still-sorting-by-one/m-p/497123#M138474</link>
      <description>&lt;P&gt;@to4kawa, thanks, but I am afraid &lt;CODE&gt;limit&lt;/CODE&gt; is not working. I saw a few posts on this forum that &lt;CODE&gt;limit&lt;/CODE&gt; does not necessarily work with chart command, and also, per documentation, "The&amp;nbsp;limit&amp;nbsp;and&amp;nbsp;agg&amp;nbsp;options are ignored if an explicit where-clause is provided", and I have a &lt;CODE&gt;where&lt;/CODE&gt; clause in my search. Also, it does not look like &lt;CODE&gt;head&lt;/CODE&gt; works with my search either. I am looking for a way to sort by values of a column-split field, and limit the data points to a specific number.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2020 20:37:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-limit-results-in-a-bar-chart-while-still-sorting-by-one/m-p/497123#M138474</guid>
      <dc:creator>nickrally2009</dc:creator>
      <dc:date>2020-03-17T20:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to limit results in a bar chart while still sorting by one of the values of column-split field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-limit-results-in-a-bar-chart-while-still-sorting-by-one/m-p/497124#M138475</link>
      <description>&lt;P&gt;If you need &lt;CODE&gt;sort&lt;/CODE&gt;, try before &lt;CODE&gt;streamstats&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2020 20:55:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-limit-results-in-a-bar-chart-while-still-sorting-by-one/m-p/497124#M138475</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-03-17T20:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to limit results in a bar chart while still sorting by one of the values of column-split field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-limit-results-in-a-bar-chart-while-still-sorting-by-one/m-p/497125#M138476</link>
      <description>&lt;P&gt;@to4kawa, thanks, I tried the search you suggested, using &lt;CODE&gt;streamstats count as session&lt;/CODE&gt; but unfortunately it resulted in only one data point: Yesterday/Today group for only one &lt;CODE&gt;id&lt;/CODE&gt;, and based on the value of &lt;CODE&gt;id&lt;/CODE&gt; it is obvious that it is sorted by &lt;CODE&gt;id&lt;/CODE&gt;, not a value in column-split field.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2020 21:17:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-limit-results-in-a-bar-chart-while-still-sorting-by-one/m-p/497125#M138476</guid>
      <dc:creator>nickrally2009</dc:creator>
      <dc:date>2020-03-17T21:17:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to limit results in a bar chart while still sorting by one of the values of column-split field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-limit-results-in-a-bar-chart-while-still-sorting-by-one/m-p/497126#M138477</link>
      <description>&lt;P&gt;Have you try &lt;CODE&gt;sort&lt;/CODE&gt; before &lt;CODE&gt;streamstats&lt;/CODE&gt;?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2020 21:24:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-limit-results-in-a-bar-chart-while-still-sorting-by-one/m-p/497126#M138477</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-03-17T21:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to limit results in a bar chart while still sorting by one of the values of column-split field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-limit-results-in-a-bar-chart-while-still-sorting-by-one/m-p/497127#M138478</link>
      <description>&lt;P&gt;yes, I did&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2020 00:26:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-limit-results-in-a-bar-chart-while-still-sorting-by-one/m-p/497127#M138478</guid>
      <dc:creator>nickrally2009</dc:creator>
      <dc:date>2020-03-18T00:26:59Z</dc:date>
    </item>
  </channel>
</rss>

