<?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: Percentage calculation based on derived value and show it is as new row in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Percentage-calculation-based-on-derived-value-and-show-it-is-as/m-p/337354#M164391</link>
    <description>&lt;P&gt;@deepa_purushothaman, for the description provided, I am expecting two columns and four rows in your data, where you want percent to be calculated based on 3rd and 4th row. Try the following run anywhere which mimics your data as per question. Commands till &lt;CODE&gt;| table column1 column2&lt;/CODE&gt; generate sample data, you would need to plug in your existing query which generates first table as per your question.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval data="XXX|10;YYY|20;abc|30;efg|10"
| makemv data delim=";"
| mvexpand data
| eval data=split(data,"|")
| eval column1=mvindex(data,0)
| eval column2=mvindex(data,1)
| table column1 column2
| transpose header_field=column1 column_name=column1
| eval perc=round((efg/abc)*100,1)
| transpose header_field=column1 column_name=column1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: This example uses &lt;CODE&gt;transpose&lt;/CODE&gt; to invert the sample table in the question and perform calculation as needed. If you can share your current search query community might be able to assist you with better query by avoiding multiple transpose. Ideally you perform event related calculation in the same row and then convert to column if required.&lt;/P&gt;</description>
    <pubDate>Tue, 12 Dec 2017 12:50:39 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-12-12T12:50:39Z</dc:date>
    <item>
      <title>Percentage calculation based on derived value and show it is as new row</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Percentage-calculation-based-on-derived-value-and-show-it-is-as/m-p/337353#M164390</link>
      <description>&lt;P&gt;My data looks something like below, here first two rows are indexed data and 3,4th rows are derived data and added as new rows after some manipulation. My question is i want to add one more new row as by calculating percentage. for example - between rows 2 &amp;amp; 3 or 3&amp;amp;4 .&lt;/P&gt;

&lt;P&gt;column1| column2&lt;BR /&gt;
XXX| 10&lt;BR /&gt;
YYY|20&lt;BR /&gt;
abc|30&lt;BR /&gt;
efg|10&lt;/P&gt;

&lt;P&gt;Outcome something like&lt;BR /&gt;
column1| column2&lt;BR /&gt;
XXX| 10&lt;BR /&gt;
YYY|20&lt;BR /&gt;
abc|30&lt;BR /&gt;
efg|10&lt;BR /&gt;
per|33 ( ie., (column1=efg/column1=abc)*100&lt;/P&gt;

&lt;P&gt;Please help. thanks &lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 11:18:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Percentage-calculation-based-on-derived-value-and-show-it-is-as/m-p/337353#M164390</guid>
      <dc:creator>deepa_purushoth</dc:creator>
      <dc:date>2017-12-12T11:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: Percentage calculation based on derived value and show it is as new row</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Percentage-calculation-based-on-derived-value-and-show-it-is-as/m-p/337354#M164391</link>
      <description>&lt;P&gt;@deepa_purushothaman, for the description provided, I am expecting two columns and four rows in your data, where you want percent to be calculated based on 3rd and 4th row. Try the following run anywhere which mimics your data as per question. Commands till &lt;CODE&gt;| table column1 column2&lt;/CODE&gt; generate sample data, you would need to plug in your existing query which generates first table as per your question.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval data="XXX|10;YYY|20;abc|30;efg|10"
| makemv data delim=";"
| mvexpand data
| eval data=split(data,"|")
| eval column1=mvindex(data,0)
| eval column2=mvindex(data,1)
| table column1 column2
| transpose header_field=column1 column_name=column1
| eval perc=round((efg/abc)*100,1)
| transpose header_field=column1 column_name=column1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: This example uses &lt;CODE&gt;transpose&lt;/CODE&gt; to invert the sample table in the question and perform calculation as needed. If you can share your current search query community might be able to assist you with better query by avoiding multiple transpose. Ideally you perform event related calculation in the same row and then convert to column if required.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 12:50:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Percentage-calculation-based-on-derived-value-and-show-it-is-as/m-p/337354#M164391</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-12-12T12:50:39Z</dc:date>
    </item>
  </channel>
</rss>

