<?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: Subtract two fields and create a timechart in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Subtract-two-fields-and-create-a-timechart/m-p/567069#M197606</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/238467"&gt;@priyangshupal&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;sorry I forgot a piece!&lt;/P&gt;&lt;P&gt;please try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=your_index
| bin span=1d _time
| stats count(skill1) AS skill1 count(skill2) AS skill2 BY _time value 
| eval diff=skill1-skill2
| table _time value diff&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
    <pubDate>Wed, 15 Sep 2021 07:55:43 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2021-09-15T07:55:43Z</dc:date>
    <item>
      <title>Subtract two fields and create a timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subtract-two-fields-and-create-a-timechart/m-p/567059#M197600</link>
      <description>&lt;P&gt;I have two fields &lt;STRONG&gt;skill1&lt;/STRONG&gt; and &lt;STRONG&gt;skill2&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;skill2:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Skill2.jpeg" style="width: 200px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/15986iF2AFD116D58AEE14/image-size/small?v=v2&amp;amp;px=200" role="button" title="Skill2.jpeg" alt="Skill2.jpeg" /&gt;&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;skill1:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Skill1.jpeg" style="width: 200px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/15987i53073EB21D5079C4/image-size/small?v=v2&amp;amp;px=200" role="button" title="Skill1.jpeg" alt="Skill1.jpeg" /&gt;&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both these queries are producing results:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;timechart span=1d count by skill1&lt;/LI-CODE&gt;&lt;LI-CODE lang="python"&gt;timechart span=1d count by skill2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a separate variable &lt;STRONG&gt;skill&amp;nbsp;&lt;/STRONG&gt;which contains difference of skill1's values and skill2's values and create a timechart out of it.&lt;/P&gt;&lt;P&gt;I tried doing:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;timechart span=1d count by skill1-skill2&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it's not working.&lt;/P&gt;&lt;P&gt;Any help would be appreciated!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 07:10:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subtract-two-fields-and-create-a-timechart/m-p/567059#M197600</guid>
      <dc:creator>priyangshupal</dc:creator>
      <dc:date>2021-09-15T07:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract two fields and create a timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subtract-two-fields-and-create-a-timechart/m-p/567060#M197601</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/238467"&gt;@priyangshupal&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;please try something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=your_index
| bin span=1d _time
| stats count(skill1) AS skill1 count(skill2) AS skill2 BY _time
| eval diff=skill1-skill2
| table _time diff&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 07:14:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subtract-two-fields-and-create-a-timechart/m-p/567060#M197601</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-09-15T07:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract two fields and create a timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subtract-two-fields-and-create-a-timechart/m-p/567065#M197603</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is not working, it's showing diff as 0.&lt;/P&gt;&lt;P&gt;Also, in the table I want the values too i.e., VALUE1, VALUE2, VALUE3 etc. The query is not showing that either.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 07:30:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subtract-two-fields-and-create-a-timechart/m-p/567065#M197603</guid>
      <dc:creator>priyangshupal</dc:creator>
      <dc:date>2021-09-15T07:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract two fields and create a timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subtract-two-fields-and-create-a-timechart/m-p/567069#M197606</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/238467"&gt;@priyangshupal&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;sorry I forgot a piece!&lt;/P&gt;&lt;P&gt;please try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=your_index
| bin span=1d _time
| stats count(skill1) AS skill1 count(skill2) AS skill2 BY _time value 
| eval diff=skill1-skill2
| table _time value diff&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 07:55:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subtract-two-fields-and-create-a-timechart/m-p/567069#M197606</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-09-15T07:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract two fields and create a timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subtract-two-fields-and-create-a-timechart/m-p/567070#M197607</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Assuming I had to replace &lt;STRONG&gt;value&amp;nbsp;&lt;/STRONG&gt;in your query with the field I want, I tried this query:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;index=your_index
| bin span=1d _time
| stats count(skill1) AS skill1 count(skill2) AS skill2 BY _time VALUE1 
| eval diff=skill1-skill2
| table _time VALUE1 diff&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But now it's showing&amp;nbsp;&lt;STRONG&gt;No results found&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Did I went wrong somewhere in the above query?&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="highlighter--icon highlighter--icon-copy"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="highlighter--separator"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="highlighter--icon highlighter--icon-change-color"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="highlighter--separator"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="highlighter--icon highlighter--icon-delete"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 15 Sep 2021 08:13:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subtract-two-fields-and-create-a-timechart/m-p/567070#M197607</guid>
      <dc:creator>priyangshupal</dc:creator>
      <dc:date>2021-09-15T08:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract two fields and create a timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subtract-two-fields-and-create-a-timechart/m-p/567073#M197608</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/238467"&gt;@priyangshupal&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;check two things:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;if the main search has results,&lt;/LI&gt;&lt;LI&gt;if VALUE1 is the name of the field (not the value but the field name).&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;if you want only the count for value=VALUE1, you can put a filter in the main search:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=your_index value=VALUE1 
| bin span=1d _time
| stats count(skill1) AS skill1 count(skill2) AS skill2 BY _time 
| eval diff=skill1-skill2
| table _time diff&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 08:24:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subtract-two-fields-and-create-a-timechart/m-p/567073#M197608</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-09-15T08:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract two fields and create a timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subtract-two-fields-and-create-a-timechart/m-p/567076#M197609</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I checked, the main search does have events. But there's no such field as VALUE1.&lt;/P&gt;&lt;P&gt;VALUE1 is present in the fields named:&amp;nbsp;&lt;STRONG&gt;skill1&amp;nbsp;&lt;/STRONG&gt;and&amp;nbsp;&lt;STRONG&gt;skill2&lt;/STRONG&gt;. (check the main post)&lt;/P&gt;&lt;P&gt;And, no I do not want the count for only VALUE1, I want the count for all the VALUEs i.e. VALUE1, VALUE2, VALUE3, VALUE4 and so on.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;What essentially I want to do is:&lt;/P&gt;&lt;P&gt;skill1.VALUE1 - skill2.VALUE1&lt;/P&gt;&lt;P&gt;skill1.VALUE2 - skill2.VALUE2&lt;/P&gt;&lt;P&gt;skill1.VALUE3 - skill2.VALUE3&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;skill1.VALUE7 - skill2.VALUE7&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I want to create a timechart out of the difference table&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 08:33:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subtract-two-fields-and-create-a-timechart/m-p/567076#M197609</guid>
      <dc:creator>priyangshupal</dc:creator>
      <dc:date>2021-09-15T08:33:42Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract two fields and create a timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subtract-two-fields-and-create-a-timechart/m-p/567077#M197610</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/238467"&gt;@priyangshupal&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;ok please, try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=your_index 
| bin span=1d _time
| stats count AS c_skill1 BY _time skill1
| append [ search 
     index=your_index 
     | bin span=1d _time
     | stats count AS c_skill2 BY _time skill2
     ]
| eval skill=coalesce(skill1,skill2)
| stats values(c_skill1) AS c_skill1 values(c_skill2) AS c_skill2 BY _time skill
| eval diff=c_skill1-c_skill2
| table _time skill diff&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 08:44:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subtract-two-fields-and-create-a-timechart/m-p/567077#M197610</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-09-15T08:44:21Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract two fields and create a timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subtract-two-fields-and-create-a-timechart/m-p/567086#M197614</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;This is very close to what I need but the&amp;nbsp;&lt;STRONG&gt;diff&amp;nbsp;&lt;/STRONG&gt;column in the table generated is empty.&lt;/P&gt;&lt;P&gt;One more thing, I observed:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;eval skill = coalesce(skill1, skill2)&lt;/LI-CODE&gt;&lt;P&gt;added values in skill1 and skill2 and created a new field&amp;nbsp;&lt;STRONG&gt;skill&lt;/STRONG&gt;&amp;nbsp;with the same values&lt;STRONG&gt;.&lt;/STRONG&gt; Isn't there a way to reverse it? I mean, instead making it add, just make it take the difference? (because that is what I want). I am new to splunk so don't know, just asking.&lt;/P&gt;&lt;P&gt;If that's not possible then can u pls tweak the last query to display &lt;STRONG&gt;diff&lt;/STRONG&gt;?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 09:21:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subtract-two-fields-and-create-a-timechart/m-p/567086#M197614</guid>
      <dc:creator>priyangshupal</dc:creator>
      <dc:date>2021-09-15T09:21:54Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract two fields and create a timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subtract-two-fields-and-create-a-timechart/m-p/567090#M197616</link>
      <description>&lt;P&gt;One thing&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can we by some way turn all values in skill2 to negative and then use the coalesce function?&lt;/P&gt;&lt;P&gt;I think this might work. Is there any way to turn all values in skill2 to negative?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I mean, if the value of skill2.VALUE1 is 300, it should turn to -300&lt;/P&gt;&lt;P&gt;And so on for VALUE2, VALUE3, VALUE4 and all others in skill2.&lt;/P&gt;&lt;P&gt;Is there any way to do it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 09:37:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subtract-two-fields-and-create-a-timechart/m-p/567090#M197616</guid>
      <dc:creator>priyangshupal</dc:creator>
      <dc:date>2021-09-15T09:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract two fields and create a timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Subtract-two-fields-and-create-a-timechart/m-p/567218#M197652</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/238467"&gt;@priyangshupal&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;the eval=coalesce... command is mandatory to have values of skill1 and skill2 in one field to use in the stats command.&lt;/P&gt;&lt;P&gt;I don't understand the request of negative skill2: a count is always a positive number and calculating difference between skill1 and skill2 you always subtract the second from the first, so what's your need?&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 16 Sep 2021 07:24:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Subtract-two-fields-and-create-a-timechart/m-p/567218#M197652</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-09-16T07:24:15Z</dc:date>
    </item>
  </channel>
</rss>

