<?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: Difference of two columns with dynamic names in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Difference-of-two-columns-with-dynamic-names/m-p/362077#M39812</link>
    <description>&lt;P&gt;This technically works for me and is what I was looking for. But the time period is actually not a standard 4 weeks duration. The end user can change it to any duration. &lt;BR /&gt;
Is it possible to incorporate dynamic weeknum too?&lt;/P&gt;</description>
    <pubDate>Mon, 19 Mar 2018 09:13:34 GMT</pubDate>
    <dc:creator>rajashekar_s</dc:creator>
    <dc:date>2018-03-19T09:13:34Z</dc:date>
    <item>
      <title>Difference of two columns with dynamic names</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Difference-of-two-columns-with-dynamic-names/m-p/362075#M39810</link>
      <description>&lt;P&gt;I am looking for a way to find the difference between two columns which are dynamic in values(time based).&lt;BR /&gt;
Here is how the query looks like-&lt;BR /&gt;
index=_internal&lt;BR /&gt;
| eval weeknum=strftime(time_field,"%Y-%V")&lt;BR /&gt;
| chart count over sourcetype by weeknum&lt;BR /&gt;
| addtotals 2*&lt;BR /&gt;
| sort- Total&lt;BR /&gt;
| head 4&lt;/P&gt;

&lt;P&gt;Sample table&lt;BR /&gt;
sourcetype  2018-03  2018-04  2018-05  2018-06 Total&lt;BR /&gt;
a                    2              3              4              5              14&lt;BR /&gt;
b                    2              1              3              5              11&lt;BR /&gt;
c                    0              0             4              5                9&lt;BR /&gt;
d                    1             1              2              3              7&lt;/P&gt;

&lt;P&gt;I am looking to calculate the difference between column 2 (2018-03) and column 5 (2018-06). &lt;BR /&gt;
As the time picker can be given with any input, the weeknum is dynamic and I need the way to calculate difference with the dynamic names of the column.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:33:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Difference-of-two-columns-with-dynamic-names/m-p/362075#M39810</guid>
      <dc:creator>rajashekar_s</dc:creator>
      <dc:date>2020-09-29T18:33:39Z</dc:date>
    </item>
    <item>
      <title>Re: Difference of two columns with dynamic names</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Difference-of-two-columns-with-dynamic-names/m-p/362076#M39811</link>
      <description>&lt;P&gt;Try this alternate implementation (Try to add one line at a time to your search to understand query functionality)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal
| eval weeknum=strftime(time_field,"%Y-%V")
| stats count by sourcetype weeknum
| streamstats count as sno by sourcetype
| appendpipe [| where sno=1 OR sno=4| chart values(count) over sourcetype by sno | eval count='1'-'4' | eval weeknum="Change" | table sourcetype weeknum count ]
| xyseries sourcetype weeknum count
| addtotals 2*
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Mar 2018 18:58:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Difference-of-two-columns-with-dynamic-names/m-p/362076#M39811</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-03-16T18:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: Difference of two columns with dynamic names</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Difference-of-two-columns-with-dynamic-names/m-p/362077#M39812</link>
      <description>&lt;P&gt;This technically works for me and is what I was looking for. But the time period is actually not a standard 4 weeks duration. The end user can change it to any duration. &lt;BR /&gt;
Is it possible to incorporate dynamic weeknum too?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 09:13:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Difference-of-two-columns-with-dynamic-names/m-p/362077#M39812</guid>
      <dc:creator>rajashekar_s</dc:creator>
      <dc:date>2018-03-19T09:13:34Z</dc:date>
    </item>
    <item>
      <title>Re: Difference of two columns with dynamic names</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Difference-of-two-columns-with-dynamic-names/m-p/362078#M39813</link>
      <description>&lt;P&gt;Assuming you always want difference of first weeknum and last (recent) weeknum, so try this variation:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal
 | eval weeknum=strftime(time_field,"%Y-%V")
 | stats count by sourcetype weeknum
 | streamstats count as sno by sourcetype
 | eventstats max(sno) as max by sourcetype
 | appendpipe [| where sno=1 OR sno=max | eval sno=if(sno=1,"first","recent") | chart values(count) over sourcetype by sno | eval count='first'-'recent' | eval weeknum="Change" | table sourcetype weeknum count ]
 | xyseries sourcetype weeknum count
 | addtotals 2*
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Mar 2018 16:33:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Difference-of-two-columns-with-dynamic-names/m-p/362078#M39813</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-03-19T16:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: Difference of two columns with dynamic names</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Difference-of-two-columns-with-dynamic-names/m-p/362079#M39814</link>
      <description>&lt;P&gt;That worked. Thanks a lot&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 07:37:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Difference-of-two-columns-with-dynamic-names/m-p/362079#M39814</guid>
      <dc:creator>rajashekar_s</dc:creator>
      <dc:date>2018-03-20T07:37:18Z</dc:date>
    </item>
  </channel>
</rss>

