<?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 fetch the corresponding value from the data which have minimum, maximum and current value for number? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-fetch-the-corresponding-value-from-the-data-which-have/m-p/598196#M208301</link>
    <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;stats&lt;/FONT&gt; command is a transforming one.&amp;nbsp; That means the only fields in the output are those mentioned in the command - in this case Minimum, Maximum, Current and dc_number.&amp;nbsp; You can use eventstats to calculate Minimum, Maximum, and Current without losing other fields.&amp;nbsp; Then you can do some manipulations to get the final result.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults | eval _raw="dc_number	argosweekstart	total_forecast
610	2022-05-22	457659.9999990086
610	2022-10-23	23534.000003657507
610	2022-06-19	457026.96672087134
610	2022-06-12	499736.9999989038"
| multikv forceheader=1
```Above just sets up test data```
```Compute min, max, and current values```
| eventstats min(total_forecast) as Minimum, max(total_forecast) as Maximum, 
latest(total_forecast) as Current by dc_number
```Find the week number that matches min, max, and current```
| eval week_cur=if(total_forecast=Current, argosweekstart, null()), week_max=if(total_forecast==Maximum, argosweekstart, null()), week_min=if(total_forecast=Minimum, argosweekstart, null())
| table dc_number week_min Minimum week_max Maximum week_cur Current
```Merge the results into a single row for each dc```
| stats values(*) as * by dc_number&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 17 May 2022 21:19:27 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2022-05-17T21:19:27Z</dc:date>
    <item>
      <title>How to fetch the corresponding value from the data which have minimum, maximum and current value for number?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fetch-the-corresponding-value-from-the-data-which-have/m-p/598071#M208263</link>
      <description>&lt;P&gt;i have the below data,&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;dc_number&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;argosweekstart&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;total_forecast&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;610&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;2022-10-23&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;23534.000003657507&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;610&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;2022-05-22&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;457659.9999990086&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;610&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;2022-06-19&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;457026.96672087134&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;610&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;2022-06-12&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;&amp;nbsp;499736.9999989038&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&lt;BR /&gt;i have fetched the below table which have maximum minimum and current data corresponding to the number from the below query&lt;BR /&gt;&lt;EM&gt;index="index"&amp;nbsp;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;|stats min(total_forecast) as Minimum max(total_forecast) as Maximum latest(total_forecast) as Current by dc_number&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;|table dc_number week_min Minimum week_max Maximum week_cur Current&lt;/EM&gt;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;dc_number&lt;/TD&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;week_min&lt;/TD&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;Minimum&lt;/TD&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;week_max&lt;/TD&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;Maximum&lt;/TD&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;week_cur&lt;/TD&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;Current&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;610&lt;/TD&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;23534.000003657507&lt;/TD&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;499736.999998903800&lt;/TD&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;23534.000003657507&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but i am expecting the below output with corresponding week value from the first table. that means, for week_min it should pick it's corresponding value from week from the minimum value and same from maximum and current. below is the expected output.&lt;/P&gt;
&lt;TABLE border="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;dc_number&lt;/TD&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;week_min&lt;/TD&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;Minimum&lt;/TD&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;week_max&lt;/TD&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;Maximum&lt;/TD&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;week_cur&lt;/TD&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;Current&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;610&lt;/TD&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;2022-10-23&lt;/TD&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;23534.000003657507&lt;/TD&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;2022-06-12&lt;/TD&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;499736.999998903800&lt;/TD&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;2022-10-23&lt;/TD&gt;
&lt;TD width="14.285714285714286%" height="25px"&gt;23534.000003657507&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Tue, 17 May 2022 14:51:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fetch-the-corresponding-value-from-the-data-which-have/m-p/598071#M208263</guid>
      <dc:creator>srujana96</dc:creator>
      <dc:date>2022-05-17T14:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to fetch the corresponding value from the data which have minimum, maximum and current value for number?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fetch-the-corresponding-value-from-the-data-which-have/m-p/598133#M208288</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="YourIndex"
| eventstats min(total_forecast) as min max(total_forecast) as max latest(total_forecast) as current by dc_number
|stats values(eval(if(total_forecast=min,argosweekstart,null()))) AS week_min min(total_forecast) AS Minimum  values(eval(if(total_forecast=max,argosweekstart,null()))) AS week_max max(total_forecast) AS Maximum values(eval(if(total_forecast=current,argosweekstart,null()))) AS week_cur latest(total_forecast) AS Current by dc_number &lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 17 May 2022 16:07:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fetch-the-corresponding-value-from-the-data-which-have/m-p/598133#M208288</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2022-05-17T16:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to fetch the corresponding value from the data which have minimum, maximum and current value for number?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fetch-the-corresponding-value-from-the-data-which-have/m-p/598196#M208301</link>
      <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;stats&lt;/FONT&gt; command is a transforming one.&amp;nbsp; That means the only fields in the output are those mentioned in the command - in this case Minimum, Maximum, Current and dc_number.&amp;nbsp; You can use eventstats to calculate Minimum, Maximum, and Current without losing other fields.&amp;nbsp; Then you can do some manipulations to get the final result.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults | eval _raw="dc_number	argosweekstart	total_forecast
610	2022-05-22	457659.9999990086
610	2022-10-23	23534.000003657507
610	2022-06-19	457026.96672087134
610	2022-06-12	499736.9999989038"
| multikv forceheader=1
```Above just sets up test data```
```Compute min, max, and current values```
| eventstats min(total_forecast) as Minimum, max(total_forecast) as Maximum, 
latest(total_forecast) as Current by dc_number
```Find the week number that matches min, max, and current```
| eval week_cur=if(total_forecast=Current, argosweekstart, null()), week_max=if(total_forecast==Maximum, argosweekstart, null()), week_min=if(total_forecast=Minimum, argosweekstart, null())
| table dc_number week_min Minimum week_max Maximum week_cur Current
```Merge the results into a single row for each dc```
| stats values(*) as * by dc_number&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 17 May 2022 21:19:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fetch-the-corresponding-value-from-the-data-which-have/m-p/598196#M208301</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-05-17T21:19:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to fetch the corresponding value from the data which have minimum, maximum and current value for number?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fetch-the-corresponding-value-from-the-data-which-have/m-p/598238#M208310</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/15147"&gt;@somesoni2&lt;/a&gt;&amp;nbsp;. it worked!!&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2022 06:41:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fetch-the-corresponding-value-from-the-data-which-have/m-p/598238#M208310</guid>
      <dc:creator>srujana96</dc:creator>
      <dc:date>2022-05-18T06:41:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to fetch the corresponding value from the data which have minimum, maximum and current value for number?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-fetch-the-corresponding-value-from-the-data-which-have/m-p/598305#M208338</link>
      <description>&lt;P&gt;If your problem is resolved, then please click the "Accept as Solution" button to help future readers.&lt;/P&gt;</description>
      <pubDate>Wed, 18 May 2022 12:42:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-fetch-the-corresponding-value-from-the-data-which-have/m-p/598305#M208338</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-05-18T12:42:45Z</dc:date>
    </item>
  </channel>
</rss>

