<?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 sum output of table command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42775#M10038</link>
    <description>&lt;P&gt;Version is 4.2.3&lt;/P&gt;</description>
    <pubDate>Mon, 26 Nov 2012 07:33:26 GMT</pubDate>
    <dc:creator>ashu_g50</dc:creator>
    <dc:date>2012-11-26T07:33:26Z</dc:date>
    <item>
      <title>How to sum output of table command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42764#M10027</link>
      <description>&lt;P&gt;Hi I have a output of the table command as below :&lt;/P&gt;

&lt;H2&gt;dataset     datacount &lt;/H2&gt;

&lt;P&gt;corp_zero   32&lt;BR /&gt;
ebz_europe  6&lt;BR /&gt;
icm 362&lt;BR /&gt;
mbs 2&lt;BR /&gt;
rm_iso  2&lt;/P&gt;

&lt;H2&gt;rm_strips   2&lt;/H2&gt;

&lt;P&gt;ebz_europe  2&lt;/P&gt;

&lt;H2&gt;icm 24&lt;/H2&gt;

&lt;P&gt;HKG_generic 2&lt;BR /&gt;
icm 72&lt;/P&gt;

&lt;H2&gt;rm_strips   1&lt;/H2&gt;

&lt;P&gt;HKG_generic 4&lt;BR /&gt;
icm 144&lt;/P&gt;

&lt;H2&gt;rm_strips   2&lt;/H2&gt;

&lt;P&gt;HKG_generic 4&lt;BR /&gt;
icm 144&lt;/P&gt;

&lt;H2&gt;rm_strips   2&lt;/H2&gt;

&lt;P&gt;corp_zero   32&lt;BR /&gt;
ebz_europe  6&lt;BR /&gt;
icm 366&lt;BR /&gt;
mbs 2&lt;BR /&gt;
rm_iso  2&lt;/P&gt;

&lt;H2&gt;rm_strips   2&lt;/H2&gt;

&lt;P&gt;and so on below is the search &lt;BR /&gt;
rex field=&lt;EM&gt;raw max_match=20 "(?i)dataSetListCountInfo&lt;/EM&gt;_(?P&lt;DATASET&gt;[^=]+)=(?P&lt;DATACOUNT&gt;\d{1,3}+)" | table dataset datacount &lt;/DATACOUNT&gt;&lt;/DATASET&gt;&lt;/P&gt;

&lt;P&gt;I want to achieve a pivot table where in the individual dataset and the corresponding numbers are sumed up.&lt;/P&gt;

&lt;P&gt;Dataset          Datacount&lt;BR /&gt;
ca_corp_zero    2&lt;BR /&gt;
corp_zero   286&lt;BR /&gt;
ebz_europe  90&lt;BR /&gt;
HKG_generic 18&lt;BR /&gt;
icm 3802&lt;BR /&gt;
mbs 16&lt;BR /&gt;
rm_agency   4&lt;BR /&gt;
rm_iso  16&lt;BR /&gt;
rm_strips   25&lt;/P&gt;

&lt;P&gt;how can I achieve this? Stats sum(datacount) by dataset after table doesnt seem to work. &lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:50:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42764#M10027</guid>
      <dc:creator>ashu_g50</dc:creator>
      <dc:date>2020-09-28T12:50:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum output of table command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42765#M10028</link>
      <description>&lt;P&gt;You need to flatten the results into unique lines 1st.&lt;/P&gt;

&lt;P&gt;There's 2 ways to do this, whats probably considered the right way&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval x=mvzip(dataset,datacount) | mvexpand x | makemv delim="," x | eval dataset=mvindex(x,0) | eval datacount=mvindex(x,1) | fields - x | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or the regex way&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval x=dataset.",".datacount | mvexpand x | rex field=x (?&amp;lt;dataset&amp;gt;.*?),(?&amp;lt;datacount&amp;gt;.*) | fields - x | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm a regex kinda person myself.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Nov 2012 09:24:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42765#M10028</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2012-11-22T09:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum output of table command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42766#M10029</link>
      <description>&lt;P&gt;Just getting rid of the &lt;CODE&gt;table&lt;/CODE&gt; command and using &lt;CODE&gt;stats&lt;/CODE&gt; directly should work.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Nov 2012 09:26:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42766#M10029</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-11-22T09:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum output of table command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42767#M10030</link>
      <description>&lt;P&gt;ok stats directly is not yeilding correct results its a bit complex refer to my other questions "Need to Extract fields"&lt;/P&gt;</description>
      <pubDate>Thu, 22 Nov 2012 09:29:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42767#M10030</guid>
      <dc:creator>ashu_g50</dc:creator>
      <dc:date>2012-11-22T09:29:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum output of table command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42768#M10031</link>
      <description>&lt;P&gt;heres te thing when I use &lt;BR /&gt;
rex field=&lt;EM&gt;raw "(?i)dataSetListCountInfo&lt;/EM&gt;_(?P&lt;DATASET&gt;[^=]+)=(?P&lt;DATACOUNT&gt;\d{1,3}+)" | stats sum(datacount) by dataset I get correct datacount numbers but wrong number of rows as the query only pics the 1st instance from different instances.&lt;/DATACOUNT&gt;&lt;/DATASET&gt;&lt;/P&gt;

&lt;P&gt;dataset     sum(datacount) &lt;BR /&gt;
HKG_generic 36&lt;BR /&gt;
ca_corp_zero    2&lt;BR /&gt;
corp_zero   280&lt;BR /&gt;
ebz_europe  2&lt;BR /&gt;
icm 58&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:51:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42768#M10031</guid>
      <dc:creator>ashu_g50</dc:creator>
      <dc:date>2020-09-28T12:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum output of table command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42769#M10032</link>
      <description>&lt;P&gt;now when i use &lt;BR /&gt;
rex field=&lt;EM&gt;raw max_match=20 "(?i)dataSetListCountInfo&lt;/EM&gt;_(?P&lt;DATASET&gt;[^=]+)=(?P&lt;DATACOUNT&gt;\d{1,3}+)" | stats sum(datacount) by dataset, I get the correct number of rows expected but you see the datacount value? its wrong.&lt;/DATACOUNT&gt;&lt;/DATASET&gt;&lt;/P&gt;

&lt;P&gt;dataset     sum(datacount) &lt;BR /&gt;
HKG_generic 2294&lt;BR /&gt;
ca_corp_zero    1534&lt;BR /&gt;
corp_zero   5185&lt;BR /&gt;
ebz_europe  5211&lt;BR /&gt;
icm 6471&lt;BR /&gt;
mbs 4993&lt;BR /&gt;
rm_agency   1594&lt;BR /&gt;
rm_iso  4993&lt;BR /&gt;
rm_strips   6193&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:51:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42769#M10032</guid>
      <dc:creator>ashu_g50</dc:creator>
      <dc:date>2020-09-28T12:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum output of table command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42770#M10033</link>
      <description>&lt;P&gt;Oh, I didn't see that these weren't unique events. You need to make it so first. Have a look at jonuwz's answer.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Nov 2012 09:47:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42770#M10033</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-11-22T09:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum output of table command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42771#M10034</link>
      <description>&lt;P&gt;Error in 'eval' command: The 'mvzip' function is unsupported or undefined.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Nov 2012 09:51:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42771#M10034</guid>
      <dc:creator>ashu_g50</dc:creator>
      <dc:date>2012-11-22T09:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum output of table command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42772#M10035</link>
      <description>&lt;P&gt;rex field=&lt;EM&gt;raw max_match=20 "(?i)dataSetListCountInfo&lt;/EM&gt;_(?P&lt;DATASET&gt;[^=]+)=(?P&lt;DATACOUNT&gt;\d{1,3}+)" | table dataset datacount |eval x=mvzip(dataset,datacount) | mvexpand x | makemv delim="," x | eval dataset=mvindex(x,0) | eval datacount=mvindex(x,1) | fields - x &lt;/DATACOUNT&gt;&lt;/DATASET&gt;&lt;/P&gt;

&lt;P&gt;am I doing something wrong?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:51:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42772#M10035</guid>
      <dc:creator>ashu_g50</dc:creator>
      <dc:date>2020-09-28T12:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum output of table command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42773#M10036</link>
      <description>&lt;P&gt;What version of splunk ?  &lt;/P&gt;

&lt;P&gt;Try using the regex method instead&lt;/P&gt;</description>
      <pubDate>Thu, 22 Nov 2012 14:13:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42773#M10036</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2012-11-22T14:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum output of table command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42774#M10037</link>
      <description>&lt;P&gt;Hi Regex method give an error &lt;/P&gt;

&lt;P&gt;Error in 'rex' command: Invalid argument: '(?&lt;DATACOUNT&gt;.*)'&lt;/DATACOUNT&gt;&lt;/P&gt;

&lt;P&gt;gfi.wellington.com accounting-service: dataSetListCountInfo | rex field=&lt;EM&gt;raw max_match=20 "(?i)dataSetListCountInfo&lt;/EM&gt;_(?P&lt;DATASET&gt;[^=]+)=(?P&lt;DATACOUNT&gt;\d{1,3}+)" |  eval x=dataset.",".datacount | mvexpand x | rex field=x (?&lt;DATASET&gt;.&lt;EM&gt;?),(?&lt;DATACOUNT&gt;.&lt;/DATACOUNT&gt;&lt;/EM&gt;) | fields - x&lt;/DATASET&gt;&lt;/DATACOUNT&gt;&lt;/DATASET&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:51:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42774#M10037</guid>
      <dc:creator>ashu_g50</dc:creator>
      <dc:date>2020-09-28T12:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum output of table command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42775#M10038</link>
      <description>&lt;P&gt;Version is 4.2.3&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2012 07:33:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42775#M10038</guid>
      <dc:creator>ashu_g50</dc:creator>
      <dc:date>2012-11-26T07:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum output of table command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42776#M10039</link>
      <description>&lt;P&gt;How to avoid this "Field 'x' does not exist in the data" while using mvzip and mvexpand&lt;/P&gt;</description>
      <pubDate>Thu, 29 Nov 2012 12:16:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-output-of-table-command/m-p/42776#M10039</guid>
      <dc:creator>smolcj</dc:creator>
      <dc:date>2012-11-29T12:16:39Z</dc:date>
    </item>
  </channel>
</rss>

