<?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: To generate two sets of values from one field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/To-generate-two-sets-of-values-from-one-field/m-p/544888#M154301</link>
    <description>&lt;P&gt;thanks! it works~&lt;/P&gt;</description>
    <pubDate>Tue, 23 Mar 2021 08:37:35 GMT</pubDate>
    <dc:creator>splunk_rookie</dc:creator>
    <dc:date>2021-03-23T08:37:35Z</dc:date>
    <item>
      <title>To generate two sets of values from one field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-generate-two-sets-of-values-from-one-field/m-p/544854#M154286</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am new to Splunk and I would like to seek help from the Splunk Community to generate the net power consumption with the following conditions:&lt;/P&gt;&lt;P&gt;1. I have two sets of assets namely A and B, which generate a power consumption value. To get the net power consumption (NPC), I will need to subtract the power value of A from B. (NPC=powerB-powerA)&lt;/P&gt;&lt;P&gt;2. The power consumption values are accumulated. To obtain the power consumed by each asset, I subtracted the earliest power value from the latest value.&amp;nbsp;(power=latest-earliest)&lt;/P&gt;&lt;P&gt;The problem which I'm facing now is I can't use the same field (power) to generate the power consumption values for asset A and B. I attempted to do a multisearch because I want both my search to run at the same time but the error which I got was "subsearch contains a non-streaming command".&lt;/P&gt;&lt;P&gt;Below is my search query:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;| multisearch&lt;/P&gt;&lt;P&gt;[ | stats latest(Power) as latest_A earliest(Power) as earliest_A by A]&lt;/P&gt;&lt;P&gt;[| stats latest(Power) as latest_B earliest(Power) as earliest_B by B]&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;| eval powerA = latestA - earliestA&amp;nbsp;&lt;/P&gt;&lt;P&gt;| eval powerB = latestB - earliestB&lt;/P&gt;&lt;P&gt;| eval NPC =&amp;nbsp; powerB - powerA&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What are the alternatives way or commands which will make my query work? Please help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Mar 2021 02:43:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-generate-two-sets-of-values-from-one-field/m-p/544854#M154286</guid>
      <dc:creator>splunk_rookie</dc:creator>
      <dc:date>2021-03-23T02:43:41Z</dc:date>
    </item>
    <item>
      <title>Re: To generate two sets of values from one field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-generate-two-sets-of-values-from-one-field/m-p/544867#M154292</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232776"&gt;@splunk_rookie&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Are the assets A and B different fields in the log file ? Or field values? &amp;nbsp;Can you please post a sample data for us to help?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Mar 2021 04:11:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-generate-two-sets-of-values-from-one-field/m-p/544867#M154292</guid>
      <dc:creator>scelikok</dc:creator>
      <dc:date>2021-03-23T04:11:19Z</dc:date>
    </item>
    <item>
      <title>Re: To generate two sets of values from one field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-generate-two-sets-of-values-from-one-field/m-p/544879#M154298</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/206061"&gt;@scelikok&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Assets A and B are from the same field. Sorry, I can't provide the sample data but let me list out the fields which I used.&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Asset&lt;/P&gt;&lt;P&gt;2. Power&lt;/P&gt;&lt;P&gt;3. _time&lt;/P&gt;&lt;P&gt;Given that the power value generated by Asset A is a regenerative energy and Asset B is consumption energy,&amp;nbsp;&amp;nbsp;I had to split the latest(power) and earliest(power) by Asset A and Asset B before subtracting them to&amp;nbsp;&lt;SPAN&gt;obtain the net power consumption.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Mar 2021 06:14:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-generate-two-sets-of-values-from-one-field/m-p/544879#M154298</guid>
      <dc:creator>splunk_rookie</dc:creator>
      <dc:date>2021-03-23T06:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: To generate two sets of values from one field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-generate-two-sets-of-values-from-one-field/m-p/544881#M154299</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232776"&gt;@splunk_rookie&lt;/a&gt;&amp;nbsp;Try below-&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats latest(Power) as latest_power earliest(Power) as earliest_power by Asset
| eval powers = latest_power - earliest_power
| stats sum(eval(if(Asset=="A",powers,0))) as A sum(eval(if(Asset=="B",powers,0))) as B 
| eval NPC = B- A&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If this helps an upvote will be appreciated!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Mar 2021 06:49:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-generate-two-sets-of-values-from-one-field/m-p/544881#M154299</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2021-03-23T06:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: To generate two sets of values from one field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/To-generate-two-sets-of-values-from-one-field/m-p/544888#M154301</link>
      <description>&lt;P&gt;thanks! it works~&lt;/P&gt;</description>
      <pubDate>Tue, 23 Mar 2021 08:37:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/To-generate-two-sets-of-values-from-one-field/m-p/544888#M154301</guid>
      <dc:creator>splunk_rookie</dc:creator>
      <dc:date>2021-03-23T08:37:35Z</dc:date>
    </item>
  </channel>
</rss>

