<?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: How to calculate the difference in count of last two columns where the columns will increase dynamically in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-calculate-the-difference-in-count-of-last-two-columns/m-p/572377#M10458</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From the lookup file i need to do transpose then I want to find the difference of last column(last 2 weeks) in new column called Difference.&lt;/P&gt;</description>
    <pubDate>Tue, 26 Oct 2021 06:21:25 GMT</pubDate>
    <dc:creator>Keerthana_18</dc:creator>
    <dc:date>2021-10-26T06:21:25Z</dc:date>
    <item>
      <title>How to calculate the difference in count of last two columns where the columns will increase dynamically</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-calculate-the-difference-in-count-of-last-two-columns/m-p/572299#M10454</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;I am new to Splunk. Could someone help me and provide the search for the below query: That would be Great!!&lt;/P&gt;&lt;P&gt;I have a search which gives below results by doing comparison of last week and current week and it shows the count of each status in weekly manner.&lt;/P&gt;&lt;TABLE border="0" width="320" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="61.375px" height="20"&gt;Date&lt;/TD&gt;&lt;TD width="62.5469px"&gt;Active&lt;/TD&gt;&lt;TD width="68.1094px"&gt;Inactive&lt;/TD&gt;&lt;TD width="67.9219px"&gt;Deleted&lt;/TD&gt;&lt;TD width="59.0469px"&gt;Added&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="61.375px" height="20"&gt;09/10/21&lt;/TD&gt;&lt;TD width="62.5469px"&gt;50&lt;/TD&gt;&lt;TD width="68.1094px"&gt;20&lt;/TD&gt;&lt;TD width="67.9219px"&gt;5&lt;/TD&gt;&lt;TD width="59.0469px"&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will be sending the above result to lookup file every week data to provide the summary.(| outputlookup append=true summary.csv)&lt;/P&gt;&lt;P&gt;The lookup file looks like below after 3 weeks.&lt;/P&gt;&lt;TABLE border="0" width="320" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="62.3438px" height="15px"&gt;Date&lt;/TD&gt;&lt;TD width="59.7344px" height="15px"&gt;Active&lt;/TD&gt;&lt;TD width="68.1094px" height="15px"&gt;Inactive&lt;/TD&gt;&lt;TD width="67.9219px" height="15px"&gt;Deleted&lt;/TD&gt;&lt;TD width="60.8906px" height="15px"&gt;Added&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="62.3438px" height="10px"&gt;09/10/2021&lt;/TD&gt;&lt;TD width="59.7344px" height="10px"&gt;50&lt;/TD&gt;&lt;TD width="68.1094px" height="10px"&gt;20&lt;/TD&gt;&lt;TD width="67.9219px" height="10px"&gt;5&lt;/TD&gt;&lt;TD width="60.8906px" height="10px"&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="62.3438px" height="15px"&gt;16/10/2021&lt;/TD&gt;&lt;TD width="59.7344px" height="15px"&gt;55&lt;/TD&gt;&lt;TD width="68.1094px" height="15px"&gt;15&lt;/TD&gt;&lt;TD width="67.9219px" height="15px"&gt;10&lt;/TD&gt;&lt;TD width="60.8906px" height="15px"&gt;30&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="62.3438px" height="15px"&gt;23/10/2021&lt;/TD&gt;&lt;TD width="59.7344px" height="15px"&gt;60&lt;/TD&gt;&lt;TD width="68.1094px" height="15px"&gt;10&lt;/TD&gt;&lt;TD width="67.9219px" height="15px"&gt;8&lt;/TD&gt;&lt;TD width="60.8906px" height="15px"&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Date column keeps on growing dynamically each week,&amp;nbsp; always I need to&amp;nbsp; calculate difference between last two column and create new column to tell the difference. The result am expecting is below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" width="320" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="64" height="20"&gt;Status&lt;/TD&gt;&lt;TD width="64"&gt;09/10/2021&lt;/TD&gt;&lt;TD width="64"&gt;16/10/2021&lt;/TD&gt;&lt;TD width="64"&gt;23/10/2021&lt;/TD&gt;&lt;TD width="64"&gt;Difference b/w last 2 columns&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;Active&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;TD&gt;55&lt;/TD&gt;&lt;TD&gt;60&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;Inactive&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;-5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;Deleted&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;-2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;Added&lt;/TD&gt;&lt;TD&gt;20&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;TD&gt;-15&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 25 Oct 2021 15:55:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-calculate-the-difference-in-count-of-last-two-columns/m-p/572299#M10454</guid>
      <dc:creator>Keerthana_18</dc:creator>
      <dc:date>2021-10-25T15:55:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the difference in count of last two columns where the columns will increase dynamically</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-calculate-the-difference-in-count-of-last-two-columns/m-p/572302#M10455</link>
      <description>&lt;P&gt;I don't understand - the second table is teansposed versus the first one. So what exactly do you want?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Oct 2021 16:39:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-calculate-the-difference-in-count-of-last-two-columns/m-p/572302#M10455</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-10-25T16:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the difference in count of last two columns where the columns will increase dynamically</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-calculate-the-difference-in-count-of-last-two-columns/m-p/572377#M10458</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From the lookup file i need to do transpose then I want to find the difference of last column(last 2 weeks) in new column called Difference.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 06:21:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-calculate-the-difference-in-count-of-last-two-columns/m-p/572377#M10458</guid>
      <dc:creator>Keerthana_18</dc:creator>
      <dc:date>2021-10-26T06:21:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the difference in count of last two columns where the columns will increase dynamically</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-calculate-the-difference-in-count-of-last-two-columns/m-p/572396#M10459</link>
      <description>&lt;P&gt;The part before the blank lines sets up dummy data and would be replaced by your search/inputlookup&lt;/P&gt;&lt;P&gt;The process is to list the values from the previous and current line, then remove the additional values for all but the last line. Then mvexpand the last line, resetting the first copy to its original state. Now the last line has both values (note the addition of the "-" for the second value), which can then be summed. Finally, transpose to get the layout required.&lt;/P&gt;&lt;P&gt;Note the use of leading underscores in some of the field names to hide them from the foreach.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw="Date	Active	Inactive	Deleted	Added
09/10/2021	50	20	5	20
16/10/2021	55	15	10	30
23/10/2021	60	10	8	15"
| multikv forceheader=1
| table Date	Active	Inactive	Deleted	Added



| streamstats list(*) as * window=2
| streamstats count as _row
| eventstats max(_row) as _last
| foreach *
    [| eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=if(_row=_last,mvappend(mvindex('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',1),"-".mvindex('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',0)),if(mvcount('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')&amp;gt;1,mvindex('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',1),'&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'))]
| mvexpand Date
| streamstats count as _copy by _row
| eval Date=if(_copy=2,"Difference",Date)
| rename Date as _Date
| foreach *
    [| eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=if(mvcount=1,&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;,if(_copy=1,mvindex(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;,0),&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;))]
| eventstats sum(*) as * by _row _copy
| rename _Date as Date
| fields - _*
| transpose 0 header_field=Date column_name=Status&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 08:52:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-calculate-the-difference-in-count-of-last-two-columns/m-p/572396#M10459</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-10-26T08:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate the difference in count of last two columns where the columns will increase dynamically</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-calculate-the-difference-in-count-of-last-two-columns/m-p/572404#M10460</link>
      <description>&lt;P&gt;Thanky&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;Great! Awesome, it worked as excepted.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 09:33:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-calculate-the-difference-in-count-of-last-two-columns/m-p/572404#M10460</guid>
      <dc:creator>Keerthana_18</dc:creator>
      <dc:date>2021-10-26T09:33:51Z</dc:date>
    </item>
  </channel>
</rss>

