<?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 to subtract field values and have the result in a new field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-field-values-and-have-the-result-in-a-new-field/m-p/380526#M111355</link>
    <description>&lt;P&gt;Hi, please view my example csv.&lt;/P&gt;

&lt;P&gt;file1.csv:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Apples  Bananas    Oranges    Grapes
50        44         83         121
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like a new column that would show the difference in each field from left to right so that the table would then look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Apples  Bananas    Oranges    Grapes    Delta
50        44         83         121       6 
                                         39
                                         38
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What SPL could I use to accomplish this?? &lt;EM&gt;In the end&lt;/EM&gt;, I intend to display the values in the &lt;CODE&gt;Delta&lt;/CODE&gt; field as a line graph visualization across the values of the fruit while they're displayed as a bar graph. I know it doesn't make much sense logically but work with me here lol.&lt;/P&gt;</description>
    <pubDate>Thu, 20 Sep 2018 20:17:28 GMT</pubDate>
    <dc:creator>russell120</dc:creator>
    <dc:date>2018-09-20T20:17:28Z</dc:date>
    <item>
      <title>How to subtract field values and have the result in a new field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-field-values-and-have-the-result-in-a-new-field/m-p/380526#M111355</link>
      <description>&lt;P&gt;Hi, please view my example csv.&lt;/P&gt;

&lt;P&gt;file1.csv:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Apples  Bananas    Oranges    Grapes
50        44         83         121
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like a new column that would show the difference in each field from left to right so that the table would then look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Apples  Bananas    Oranges    Grapes    Delta
50        44         83         121       6 
                                         39
                                         38
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What SPL could I use to accomplish this?? &lt;EM&gt;In the end&lt;/EM&gt;, I intend to display the values in the &lt;CODE&gt;Delta&lt;/CODE&gt; field as a line graph visualization across the values of the fruit while they're displayed as a bar graph. I know it doesn't make much sense logically but work with me here lol.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2018 20:17:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-field-values-and-have-the-result-in-a-new-field/m-p/380526#M111355</guid>
      <dc:creator>russell120</dc:creator>
      <dc:date>2018-09-20T20:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract field values and have the result in a new field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-field-values-and-have-the-result-in-a-new-field/m-p/380527#M111356</link>
      <description>&lt;P&gt;hi @russell120 &lt;/P&gt;

&lt;P&gt;can u try like this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults |eval  Apples=50,Bananas=44,Oranges=83,Grapes=121 |table  Apples Bananas Oranges Grapes|transpose |delta "row 1" as delta|transpose header_field=column |fields - column
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Sep 2018 06:07:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-field-values-and-have-the-result-in-a-new-field/m-p/380527#M111356</guid>
      <dc:creator>harishalipaka</dc:creator>
      <dc:date>2018-09-21T06:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to subtract field values and have the result in a new field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-field-values-and-have-the-result-in-a-new-field/m-p/380528#M111357</link>
      <description>&lt;P&gt;@russell120,&lt;/P&gt;

&lt;P&gt;If you have defined number of columns, then try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"your search" |eval Delta=abs(Apples-Bananas)."#".abs(Bananas-Oranges)."#".abs(Oranges-Grapes)|makemv delim="#" Delta
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 22 Sep 2018 05:19:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-subtract-field-values-and-have-the-result-in-a-new-field/m-p/380528#M111357</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-09-22T05:19:25Z</dc:date>
    </item>
  </channel>
</rss>

