<?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: stats/streamstats to display only last 2 result/row in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/stats-streamstats-to-display-only-last-2-result-row/m-p/551773#M156583</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/233446"&gt;@yuming1127&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try this.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;YOUR_SEARCH
| eval a=1 | accum a | eventstats max(a) as mx | where a=mx OR a=mx-1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="product	color	product_tag	description
phone	red	abc_1	blabla1
phone	red	abc_2	blabla2
phone	red	abc_3	blabla3
phone	red	abc_4	blabla4" 
| multikv forceheader=1 
| table product color product_tag description
| eval a=1 | accum a | eventstats max(a) as mx | where a=mx OR a=mx-1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;KV&lt;BR /&gt;▄︻̷̿┻̿═━一&lt;BR /&gt;&lt;BR /&gt;If this reply helps you, an upvote would be appreciated.&lt;/P&gt;</description>
    <pubDate>Mon, 17 May 2021 04:29:41 GMT</pubDate>
    <dc:creator>kamlesh_vaghela</dc:creator>
    <dc:date>2021-05-17T04:29:41Z</dc:date>
    <item>
      <title>stats/streamstats to display only last 2 result/row</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-streamstats-to-display-only-last-2-result-row/m-p/551771#M156582</link>
      <description>&lt;P&gt;Hi, i'm looking for a solution which only show the last and last-1 result using stats or streamstats function.&amp;nbsp; Aim is to only display something like &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;max(row) and max(row)-1&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;my search...&lt;/P&gt;&lt;P&gt;| stats values(product_tag*) as product_tag* values(*) as * by product,color,product_tag&lt;/P&gt;&lt;P&gt;&lt;U&gt;outcome&lt;/U&gt;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;product&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;color&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;product_tag&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;description&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;phone&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;red&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;abc_1&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;blabla1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;phone&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;red&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;abc_2&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;blabla2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;phone&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;red&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;abc_3&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;blabla3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;phone&lt;/TD&gt;&lt;TD&gt;red&lt;/TD&gt;&lt;TD&gt;abc_4&lt;/TD&gt;&lt;TD&gt;blabla4&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;desired outcome&lt;/U&gt;&lt;/P&gt;&lt;TABLE border="1" width="344px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="98.4px" height="24px"&gt;product&lt;/TD&gt;&lt;TD width="98.4px" height="24px"&gt;color&lt;/TD&gt;&lt;TD width="100.8px" height="24px"&gt;product_tag&lt;/TD&gt;&lt;TD width="45.6px"&gt;description&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="98.4px" height="24px"&gt;phone&lt;/TD&gt;&lt;TD width="98.4px" height="24px"&gt;red&lt;/TD&gt;&lt;TD width="100.8px" height="24px"&gt;abc_3&lt;/TD&gt;&lt;TD width="45.6px"&gt;blabla3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="98.4px" height="24px"&gt;phone&lt;/TD&gt;&lt;TD width="98.4px" height="24px"&gt;red&lt;/TD&gt;&lt;TD width="100.8px" height="24px"&gt;abc_4&lt;/TD&gt;&lt;TD width="45.6px"&gt;blabla4&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;or&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="98.4px" height="24px"&gt;product&lt;/TD&gt;&lt;TD width="98.4px" height="24px"&gt;color&lt;/TD&gt;&lt;TD width="100.8px" height="24px"&gt;product_tag&lt;/TD&gt;&lt;TD width="45.6px"&gt;description&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="98.4px" height="24px"&gt;phone&lt;/TD&gt;&lt;TD width="98.4px" height="24px"&gt;red&lt;/TD&gt;&lt;TD width="100.8px" height="24px"&gt;abc_4&lt;/TD&gt;&lt;TD width="45.6px"&gt;blabla4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="98.4px" height="24px"&gt;phone&lt;/TD&gt;&lt;TD width="98.4px" height="24px"&gt;red&lt;/TD&gt;&lt;TD width="100.8px" height="24px"&gt;abc_3&lt;/TD&gt;&lt;TD width="45.6px"&gt;blabla3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 May 2021 03:52:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-streamstats-to-display-only-last-2-result-row/m-p/551771#M156582</guid>
      <dc:creator>yuming1127</dc:creator>
      <dc:date>2021-05-17T03:52:29Z</dc:date>
    </item>
    <item>
      <title>Re: stats/streamstats to display only last 2 result/row</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-streamstats-to-display-only-last-2-result-row/m-p/551773#M156583</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/233446"&gt;@yuming1127&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try this.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;YOUR_SEARCH
| eval a=1 | accum a | eventstats max(a) as mx | where a=mx OR a=mx-1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="product	color	product_tag	description
phone	red	abc_1	blabla1
phone	red	abc_2	blabla2
phone	red	abc_3	blabla3
phone	red	abc_4	blabla4" 
| multikv forceheader=1 
| table product color product_tag description
| eval a=1 | accum a | eventstats max(a) as mx | where a=mx OR a=mx-1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;KV&lt;BR /&gt;▄︻̷̿┻̿═━一&lt;BR /&gt;&lt;BR /&gt;If this reply helps you, an upvote would be appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 17 May 2021 04:29:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-streamstats-to-display-only-last-2-result-row/m-p/551773#M156583</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2021-05-17T04:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: stats/streamstats to display only last 2 result/row</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-streamstats-to-display-only-last-2-result-row/m-p/551775#M156584</link>
      <description>&lt;P&gt;Great one KV,&lt;/P&gt;&lt;P&gt;one more addition question,&amp;nbsp; &lt;SPAN&gt;how do i display the product_tag i search and the one previous of it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;For example:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;my search...&lt;/P&gt;&lt;P&gt;| stats values(product_tag*) as product_tag* values(*) as * by product,color,product_tag&lt;/P&gt;&lt;P&gt;|&amp;nbsp; search&amp;nbsp;&lt;SPAN&gt;product_tag=abc_3&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Outcome&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;product&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;color&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;product_tag&lt;/TD&gt;&lt;TD&gt;description&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;phone&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;red&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;abc_3&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;blabla3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Desired outcome&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;t&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;color&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;product_tag&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;description&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;phone&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;red&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;abc_2&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;blabla2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;phone&lt;/TD&gt;&lt;TD width="33.333333333333336%" height="24px"&gt;red&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;abc_3&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="24px"&gt;blabla3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;really appreciate your help.&lt;/P&gt;</description>
      <pubDate>Mon, 17 May 2021 05:13:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-streamstats-to-display-only-last-2-result-row/m-p/551775#M156584</guid>
      <dc:creator>yuming1127</dc:creator>
      <dc:date>2021-05-17T05:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: stats/streamstats to display only last 2 result/row</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-streamstats-to-display-only-last-2-result-row/m-p/551777#M156585</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/233446"&gt;@yuming1127&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For your search product_tag &amp;nbsp;scenario try this.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;YOUR_SEARCH
| eval a=1 , search_product_tag="YOUR_SEARCH_TAG"
| accum a 
| eventstats max(eval(if(search_product_tag==product_tag,a,null()))) as mx
| where a=mx OR a=mx-1
| table product	color	product_tag	description&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample Search:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="product	color	product_tag	description
phone	red	abc_1	blabla1
phone	red	abc_2	blabla2
phone	red	abc_3	blabla3
phone	red	abc_4	blabla4" 
| multikv forceheader=1 
| table product color product_tag description 
| eval a=1 , search_product_tag="abc_3"
| accum a 
| eventstats max(eval(if(search_product_tag==product_tag,a,null()))) as mx
| where a=mx OR a=mx-1
| table product	color	product_tag	description&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;KV&lt;BR /&gt;▄︻̷̿┻̿═━一&lt;BR /&gt;&lt;BR /&gt;If this reply helps you, an upvote would be appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 17 May 2021 05:27:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-streamstats-to-display-only-last-2-result-row/m-p/551777#M156585</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2021-05-17T05:27:24Z</dc:date>
    </item>
  </channel>
</rss>

