<?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: Help with temp tables / variables in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Help-with-temp-tables-and-variables/m-p/587358#M204563</link>
    <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/243555"&gt;@AK89&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Can you try running the below query? I believe it should help you achieve your use case. You can use multiple latest functions and group by the target.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sourcetype=xyz (Disk_Group = "Data*")
| stats latest(Usable_Free_GB) as latestusable latest(Usable_Total_GB) as latesttotal by Target_Name Disk_Group
| stats sum(latestusable) as UsableFree sum(latesttotal) as UsableTotal by Target_Name
| eval percent_free = round(((UsableFree/UsableTotal)*100),2)
| table Target_Name UsableFree UsableTotal precent_free&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 03 Mar 2022 05:55:20 GMT</pubDate>
    <dc:creator>tshah-splunk</dc:creator>
    <dc:date>2022-03-03T05:55:20Z</dc:date>
    <item>
      <title>Help with temp tables and variables</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-temp-tables-and-variables/m-p/587338#M204560</link>
      <description>&lt;P&gt;New to splunk and been struggling manipulating search results into a final result that I am looking for. In powershell where I'm familiar, I would just use a series of variables and return a final result set. I am trying to accomplish the below.&lt;/P&gt;
&lt;P&gt;(each target_name has multiple disk_group)&lt;/P&gt;
&lt;P&gt;1) i need to fin&lt;SPAN&gt;d the latest&amp;nbsp;Usable_Free_GB for each disk_group in each&amp;nbsp;target_name and sum them&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-03-02 210151.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/18237i76C9A1C7AEB3EF0F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2022-03-02 210151.png" alt="Screenshot 2022-03-02 210151.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;2) i ne&lt;SPAN&gt;ed to find th&lt;/SPAN&gt;&lt;SPAN&gt;e latest Usable_Total_GB for each disk_group in each&amp;nbsp;target_name and sum them&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-03-02 210209.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/18238i49FFD08CAFC53514/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2022-03-02 210209.png" alt="Screenshot 2022-03-02 210209.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I can get #1 and #2&lt;SPAN&gt;&amp;nbsp;in&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;different searches, but am struggling to get them together to return a result set like this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;Target_Name&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;UsableSpaceFree&lt;/TD&gt;
&lt;TD width="33.333333333333336%" height="25px"&gt;TotalUsableSpace&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="25px"&gt;Target_Name1&lt;/TD&gt;
&lt;TD height="25px"&gt;123&lt;/TD&gt;
&lt;TD height="25px"&gt;456&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="25px"&gt;Target_Name2&lt;/TD&gt;
&lt;TD height="25px"&gt;234&lt;/TD&gt;
&lt;TD height="25px"&gt;567&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is the closest I can get. But I need to only have 2 rows returned with all three fields populated&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-03-02 211537.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/18240i028A520FFE37C077/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2022-03-02 211537.png" alt="Screenshot 2022-03-02 211537.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;O&lt;SPAN&gt;nce I can get the result set grouped by Target_Name, I then need to use eval to create a new field like the below using the values from #1 and #2&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;eval percent_free=round((UsableSpaceFree/TotalUsableSpace)*100,2)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="774.0000000000002px"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="252.45px" height="25px"&gt;Target_Name&lt;/TD&gt;
&lt;TD width="253.238px" height="25px"&gt;UsableSpaceFree&lt;/TD&gt;
&lt;TD width="141.825px" height="25px"&gt;TotalUsableSpace&lt;/TD&gt;
&lt;TD width="125.488px"&gt;percent_free&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="252.45px" height="25px"&gt;Target_Name1&lt;/TD&gt;
&lt;TD width="253.238px" height="25px"&gt;123&lt;/TD&gt;
&lt;TD width="141.825px" height="25px"&gt;456&lt;/TD&gt;
&lt;TD width="125.488px"&gt;?&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="252.45px" height="25px"&gt;Target_Name2&lt;/TD&gt;
&lt;TD width="253.238px" height="25px"&gt;234&lt;/TD&gt;
&lt;TD width="141.825px" height="25px"&gt;567&lt;/TD&gt;
&lt;TD width="125.488px"&gt;?&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 17:25:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-temp-tables-and-variables/m-p/587338#M204560</guid>
      <dc:creator>AK89</dc:creator>
      <dc:date>2022-03-03T17:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: Help with temp tables / variables</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-temp-tables-and-variables/m-p/587357#M204562</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/243555"&gt;@AK89&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;you can use multiple&amp;nbsp; funcation in same stats command&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;sourcetype=xyz Disk_Group="*Data*"&lt;BR /&gt;| stats latest(Usable_Free_GB) as LatestUsable&amp;nbsp; latest(Usable_Total_GB) as LastestTotal&amp;nbsp; by Target_Name Disk_Group&lt;BR /&gt;&lt;BR /&gt;| stats sum(LatestUsable) as UsableSpaceFree sum(LastestTotal) as TotalUsableSpace&amp;nbsp; count(eval(round((UsableSpaceFree/TotalUsableSpace)*100,2))) as percent_free by&amp;nbsp;Target_Name&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 05:59:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-temp-tables-and-variables/m-p/587357#M204562</guid>
      <dc:creator>SanjayReddy</dc:creator>
      <dc:date>2022-03-03T05:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Help with temp tables / variables</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-temp-tables-and-variables/m-p/587358#M204563</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/243555"&gt;@AK89&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Can you try running the below query? I believe it should help you achieve your use case. You can use multiple latest functions and group by the target.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sourcetype=xyz (Disk_Group = "Data*")
| stats latest(Usable_Free_GB) as latestusable latest(Usable_Total_GB) as latesttotal by Target_Name Disk_Group
| stats sum(latestusable) as UsableFree sum(latesttotal) as UsableTotal by Target_Name
| eval percent_free = round(((UsableFree/UsableTotal)*100),2)
| table Target_Name UsableFree UsableTotal precent_free&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 03 Mar 2022 05:55:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-temp-tables-and-variables/m-p/587358#M204563</guid>
      <dc:creator>tshah-splunk</dc:creator>
      <dc:date>2022-03-03T05:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: Help with temp tables / variables</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-temp-tables-and-variables/m-p/587432#M204578</link>
      <description>&lt;P&gt;Thanks. I tried using multiple functions on same command but i must have been messing something up. Thanks for helping me with such a simple question!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 13:10:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-temp-tables-and-variables/m-p/587432#M204578</guid>
      <dc:creator>AK89</dc:creator>
      <dc:date>2022-03-03T13:10:57Z</dc:date>
    </item>
  </channel>
</rss>

