<?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 can I derive a field based on the existing two fields? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-derive-a-field-based-on-the-existing-two-fields/m-p/422110#M174284</link>
    <description>&lt;P&gt;Hello All,&lt;/P&gt;

&lt;P&gt;I am new to Splunk, and in need of help for below events:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;[testName="MobileExp",experience="FetchOn"]&lt;/LI&gt;
&lt;LI&gt;[testName="MobileExp",experience="FetchOff"]&lt;/LI&gt;
&lt;LI&gt;[testName="ProductDesign",experience="A"]&lt;/LI&gt;
&lt;LI&gt;[testName="ProductDesign",experience="B"]&lt;/LI&gt;
&lt;LI&gt;[testName="ProductDesign",experience="C"]&lt;/LI&gt;
&lt;LI&gt;[testName="ProductDesign",experience="B"]&lt;/LI&gt;
&lt;LI&gt;[testName="ProductDesign",experience="B"]&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Using  above events, I wanted to derive a field which would have percentage for each "experience" of a "testName". For example, for testName="MobileExp", there are two experiences, each of them appearing exactly once. So, percentage split for the experiences relating to testName="MobileExp" is 50%.&lt;/P&gt;

&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
    <pubDate>Tue, 04 Dec 2018 04:51:39 GMT</pubDate>
    <dc:creator>newsplnkr</dc:creator>
    <dc:date>2018-12-04T04:51:39Z</dc:date>
    <item>
      <title>How can I derive a field based on the existing two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-derive-a-field-based-on-the-existing-two-fields/m-p/422110#M174284</link>
      <description>&lt;P&gt;Hello All,&lt;/P&gt;

&lt;P&gt;I am new to Splunk, and in need of help for below events:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;[testName="MobileExp",experience="FetchOn"]&lt;/LI&gt;
&lt;LI&gt;[testName="MobileExp",experience="FetchOff"]&lt;/LI&gt;
&lt;LI&gt;[testName="ProductDesign",experience="A"]&lt;/LI&gt;
&lt;LI&gt;[testName="ProductDesign",experience="B"]&lt;/LI&gt;
&lt;LI&gt;[testName="ProductDesign",experience="C"]&lt;/LI&gt;
&lt;LI&gt;[testName="ProductDesign",experience="B"]&lt;/LI&gt;
&lt;LI&gt;[testName="ProductDesign",experience="B"]&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Using  above events, I wanted to derive a field which would have percentage for each "experience" of a "testName". For example, for testName="MobileExp", there are two experiences, each of them appearing exactly once. So, percentage split for the experiences relating to testName="MobileExp" is 50%.&lt;/P&gt;

&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 04:51:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-derive-a-field-based-on-the-existing-two-fields/m-p/422110#M174284</guid>
      <dc:creator>newsplnkr</dc:creator>
      <dc:date>2018-12-04T04:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: How can I derive a field based on the existing two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-derive-a-field-based-on-the-existing-two-fields/m-p/422111#M174285</link>
      <description>&lt;P&gt;@newsplnkr ,&lt;/P&gt;

&lt;P&gt;Try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"your base search "|eventstats count by testName,experience
|eventstats sum(count) as total by testName
|eval perc=round((count/total)*100,2)|fields - count,total
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Dec 2018 06:43:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-derive-a-field-based-on-the-existing-two-fields/m-p/422111#M174285</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-12-04T06:43:15Z</dc:date>
    </item>
    <item>
      <title>Re: How can I derive a field based on the existing two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-derive-a-field-based-on-the-existing-two-fields/m-p/422112#M174286</link>
      <description>&lt;P&gt;Hi Renjith, unfortunately, the above query does not produce any results.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 13:52:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-derive-a-field-based-on-the-existing-two-fields/m-p/422112#M174286</guid>
      <dc:creator>newsplnkr</dc:creator>
      <dc:date>2018-12-04T13:52:09Z</dc:date>
    </item>
    <item>
      <title>Re: How can I derive a field based on the existing two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-derive-a-field-based-on-the-existing-two-fields/m-p/422113#M174287</link>
      <description>&lt;P&gt;I figured out the answer with the help of @renjith.nair.&lt;/P&gt;

&lt;P&gt;The following worked:&lt;/P&gt;

&lt;P&gt;"baseSearch"&lt;BR /&gt;
| eventstats count as testCount by testName &lt;BR /&gt;
| eventstats count as expTotal by  experience&lt;BR /&gt;
| eval trafficSplit=round((expTotal/testCount)*100,1) | fields - expTotal, testCount&lt;BR /&gt;
| table  testName experience trafficSplit | dedup testName experience trafficSplit&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 16:51:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-derive-a-field-based-on-the-existing-two-fields/m-p/422113#M174287</guid>
      <dc:creator>newsplnkr</dc:creator>
      <dc:date>2018-12-04T16:51:43Z</dc:date>
    </item>
    <item>
      <title>Re: How can I derive a field based on the existing two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-derive-a-field-based-on-the-existing-two-fields/m-p/422114#M174288</link>
      <description>&lt;P&gt;Try this search, replace the base search as per your data :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval Data="testName:MobileExp,experience:FetchOn;testName:MobileExp,experience:FetchOff;testName:ProductDesign,experience:A;testName:ProductDesign,experience:C;testName:ProductDesign,experience:B;testName:ProductDesign,experience:B" 
| makemv delim=";" Data 
| mvexpand Data 
| eval Split1=mvindex(split(Data,","),0) 
| eval Split2=mvindex(split(Data,","),1) | eval testName=mvindex(split(Split1,":"),1) | eval experience=mvindex(split(Split2,":"),1) | table _time testName experience | eventstats count as test_count by testName experience | eventstats sum(test_count) as Total by testName | eval perc=(test_count/Total*100)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Dec 2018 16:58:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-derive-a-field-based-on-the-existing-two-fields/m-p/422114#M174288</guid>
      <dc:creator>macadminrohit</dc:creator>
      <dc:date>2018-12-04T16:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: How can I derive a field based on the existing two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-derive-a-field-based-on-the-existing-two-fields/m-p/422115#M174289</link>
      <description>&lt;P&gt;Accept the answer&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 17:10:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-derive-a-field-based-on-the-existing-two-fields/m-p/422115#M174289</guid>
      <dc:creator>skoelpin</dc:creator>
      <dc:date>2018-12-04T17:10:01Z</dc:date>
    </item>
    <item>
      <title>Re: How can I derive a field based on the existing two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-derive-a-field-based-on-the-existing-two-fields/m-p/422116#M174290</link>
      <description>&lt;P&gt;question: why you are &lt;CODE&gt;deduping&lt;/CODE&gt; at the end ?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Dec 2018 17:18:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-derive-a-field-based-on-the-existing-two-fields/m-p/422116#M174290</guid>
      <dc:creator>macadminrohit</dc:creator>
      <dc:date>2018-12-04T17:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: How can I derive a field based on the existing two fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-derive-a-field-based-on-the-existing-two-fields/m-p/422117#M174291</link>
      <description>&lt;P&gt;I did it to remove any duplicate records&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 21:35:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-derive-a-field-based-on-the-existing-two-fields/m-p/422117#M174291</guid>
      <dc:creator>newsplnkr</dc:creator>
      <dc:date>2018-12-20T21:35:36Z</dc:date>
    </item>
  </channel>
</rss>

