<?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: Compute last two columns with dynamic table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Compute-last-two-columns-with-dynamic-table/m-p/345451#M102350</link>
    <description>&lt;P&gt;as I've said the number of columns is not fixed, so there can be columns 1,2,3,4,5 &lt;/P&gt;</description>
    <pubDate>Mon, 05 Feb 2018 05:45:35 GMT</pubDate>
    <dc:creator>michaelrosello</dc:creator>
    <dc:date>2018-02-05T05:45:35Z</dc:date>
    <item>
      <title>Compute last two columns with dynamic table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compute-last-two-columns-with-dynamic-table/m-p/345449#M102348</link>
      <description>&lt;P&gt;So I have a table that looks like this. What I want is to another column based on the last two column of my table with a formula of latestcolumn(column3) / previouscolumn(column2).&lt;/P&gt;

&lt;P&gt;my problem is the number of columns is dynamic which mean I can have a up to 8 columns.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;title column1  column2 column3
A         1      2       3
B         4      5       6
C         7      8       9
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is the search i used to get my initial table&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main 
| xyseries title column count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Feb 2018 02:12:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compute-last-two-columns-with-dynamic-table/m-p/345449#M102348</guid>
      <dc:creator>michaelrosello</dc:creator>
      <dc:date>2018-02-05T02:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: Compute last two columns with dynamic table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compute-last-two-columns-with-dynamic-table/m-p/345450#M102349</link>
      <description>&lt;P&gt;You can try something like this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main 
 | xyseries title column count | eval column4=round(column3/column2,2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if this helps!&lt;/P&gt;</description>
      <pubDate>Mon, 05 Feb 2018 03:42:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compute-last-two-columns-with-dynamic-table/m-p/345450#M102349</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2018-02-05T03:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: Compute last two columns with dynamic table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compute-last-two-columns-with-dynamic-table/m-p/345451#M102350</link>
      <description>&lt;P&gt;as I've said the number of columns is not fixed, so there can be columns 1,2,3,4,5 &lt;/P&gt;</description>
      <pubDate>Mon, 05 Feb 2018 05:45:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compute-last-two-columns-with-dynamic-table/m-p/345451#M102350</guid>
      <dc:creator>michaelrosello</dc:creator>
      <dc:date>2018-02-05T05:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: Compute last two columns with dynamic table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Compute-last-two-columns-with-dynamic-table/m-p/345452#M102351</link>
      <description>&lt;P&gt;Maybe, this way will suit you.&lt;/P&gt;

&lt;PRE&gt;index=main 
| xyseries title, column, count 
| join title 
    [ search index=main 
    | eventstats values(column) as vals, dc(column) as colcount 
    | eval last=mvindex(vals, colcount-1), prev=mvindex(vals, colcount-2) 
    | where column=last OR column=prev 
    | eval column=if(column=last, "last", "prev") 
    | xyseries title, column, count
    | eval result=prev/last 
    | fields - last, prev]
&lt;/PRE&gt;

&lt;P&gt;Though, I believe it's possible to implement it easier.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Feb 2018 08:56:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Compute-last-two-columns-with-dynamic-table/m-p/345452#M102351</guid>
      <dc:creator>nryabykh</dc:creator>
      <dc:date>2018-02-05T08:56:53Z</dc:date>
    </item>
  </channel>
</rss>

