<?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: From fields values make a table with calculated fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/From-fields-values-make-a-table-with-calculated-fields/m-p/432406#M123553</link>
    <description>&lt;P&gt;@dfofie,&lt;/P&gt;

&lt;P&gt;Does this work for you ?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"your search"
|rename field* as Field*|fields Field*|transpose  column_name="Fields"
|rename "row *" as "row*"|eval Is_TRUE=0,Is_False=0
|foreach * [eval Is_TRUE=if(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=="true",Is_TRUE+1,Is_TRUE+0),Is_False=if(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=="false",Is_False+1,Is_False+0)]
|fields Fields,Is_TRUE,Is_False
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 28 Aug 2018 14:22:52 GMT</pubDate>
    <dc:creator>renjith_nair</dc:creator>
    <dc:date>2018-08-28T14:22:52Z</dc:date>
    <item>
      <title>From fields values make a table with calculated fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/From-fields-values-make-a-table-with-calculated-fields/m-p/432404#M123551</link>
      <description>&lt;P&gt;Hi Everyone,&lt;BR /&gt;
I'm new to Splunk: our Data looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;gt;     id;name;Field1;Field2;Field3;Field4;field5;field6;field7
&amp;gt;     0;Module Name 0;true;false;true;true;false;true;true
&amp;gt;     1;Module Name 1;true;false;false;true;false;false;false
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;We would like to build a table that looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;----------------------------------------------
FieldName|  Is_TRUE|   is_False|
field1         |    10        |    20        |
field2         |    10        |    20        |
field3         |    10        |    20        |
----------------------------------------------
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The columns "is_true" and "is_False" are the sum of the times where field* is True and respectively False.&lt;BR /&gt;
How do I get something like this ? Is there a Special Query for that ? &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:04:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/From-fields-values-make-a-table-with-calculated-fields/m-p/432404#M123551</guid>
      <dc:creator>dfofie</dc:creator>
      <dc:date>2020-09-29T21:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: From fields values make a table with calculated fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/From-fields-values-make-a-table-with-calculated-fields/m-p/432405#M123552</link>
      <description>&lt;P&gt;Try using the      transpose       function. Try running the following steps&lt;/P&gt;

&lt;P&gt;run search&lt;BR /&gt;
  | REST /services/data/indexes | table title, splunk_server, currentDBSizeMB &lt;/P&gt;

&lt;P&gt;It should produce a table something like this.&lt;/P&gt;

&lt;P&gt;title                       splunk_server                          currentDBSizeMB&lt;BR /&gt;&lt;BR /&gt;
_audit                  vmphqm1dsc1ax06                        1&lt;BR /&gt;
_internal           vmphqm1dsc1ax06                        1&lt;BR /&gt;
_introspection  vmphqm1dsc1ax06                        1&lt;BR /&gt;
_telemetry          vmphqm1dsc1ax06                        1 &lt;BR /&gt;
.&lt;BR /&gt;
.&lt;/P&gt;

&lt;P&gt;Now run the same search with the added       transpose  function.&lt;BR /&gt;
    | REST /services/data/indexes | table title, splunk_server, currentDBSizeMB | transpose&lt;/P&gt;

&lt;P&gt;It should cause the columns to be rows and vise versa.  You should get a table like this.&lt;/P&gt;

&lt;P&gt;column                      row 1                              row 2                        row 3                      row 4                         row 5&lt;BR /&gt;&lt;BR /&gt;
title                              _audit                                 _internal                             _introspection         _telemetry                   _thefishbucket&lt;BR /&gt;
splunk_server       vmphqm1dsc1ax06     vmphqm1dsc1ax06     vmphqm1dsc1ax06     vmphqm1dsc1ax06     vmphqm1dsc1ax06&lt;BR /&gt;
currentDBSizeMB     1                                            1                                   1                                  1                                    1 &lt;/P&gt;

&lt;P&gt;Hope this helps. Here is a link to all the SPL commands.&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/7.1.2/SearchReference/Abstract#collapseDesktop6" target="_blank"&gt;http://docs.splunk.com/Documentation/Splunk/7.1.2/SearchReference/Abstract#collapseDesktop6&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:02:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/From-fields-values-make-a-table-with-calculated-fields/m-p/432405#M123552</guid>
      <dc:creator>JackNobrega</dc:creator>
      <dc:date>2020-09-29T21:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: From fields values make a table with calculated fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/From-fields-values-make-a-table-with-calculated-fields/m-p/432406#M123553</link>
      <description>&lt;P&gt;@dfofie,&lt;/P&gt;

&lt;P&gt;Does this work for you ?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"your search"
|rename field* as Field*|fields Field*|transpose  column_name="Fields"
|rename "row *" as "row*"|eval Is_TRUE=0,Is_False=0
|foreach * [eval Is_TRUE=if(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=="true",Is_TRUE+1,Is_TRUE+0),Is_False=if(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=="false",Is_False+1,Is_False+0)]
|fields Fields,Is_TRUE,Is_False
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Aug 2018 14:22:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/From-fields-values-make-a-table-with-calculated-fields/m-p/432406#M123553</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2018-08-28T14:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: From fields values make a table with calculated fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/From-fields-values-make-a-table-with-calculated-fields/m-p/432407#M123554</link>
      <description>&lt;P&gt;try something like this...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(your search, or use run-anywhere base search below) 
| rename COMMENT as "Kill name field because we only need one generic id field for untable"
| fields - name

| rename COMMENT as "Turn each record into one record per field"
| untable id fieldname fieldvalue

| rename COMMENT as "Sum up the counts by fieldname and fieldvalue (true or false)"
| stats count as mycount by fieldname fieldvalue

| rename COMMENT as "Turn into a chart"
| chart sum(mycount) as count by fieldname fieldvalue

| rename COMMENT as "Optionally, put zeroes in blank cells"
| fillnull
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;You can use this as a base search for run-anywhere testing &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval mydata="0;Module Name 0;true;false;true;true;false;true;true!!!!1;Module Name 1;true;false;false;true;false;false;false"
| makemv delim="!!!!" mydata
| mvexpand mydata
| makemv delim=";" mydata
| eval  id = mvindex(mydata,0), name = mvindex(mydata,1), Field1 = mvindex(mydata,2), Field2 = mvindex(mydata,3), Field3 = mvindex(mydata,4), Field4 = mvindex(mydata,5), field5 = mvindex(mydata,6), field6 = mvindex(mydata,7), field7 = mvindex(mydata,8)
| fields - _time mydata 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Aug 2018 15:29:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/From-fields-values-make-a-table-with-calculated-fields/m-p/432407#M123554</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-08-28T15:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: From fields values make a table with calculated fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/From-fields-values-make-a-table-with-calculated-fields/m-p/432408#M123555</link>
      <description>&lt;P&gt;Hi @dfofie,  Did either of the answers below solve your question? If yes, please click “Accept” directly below the answer to resolve the post. If not, please comment with more information if you are still having issues. Thanks!!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 19:45:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/From-fields-values-make-a-table-with-calculated-fields/m-p/432408#M123555</guid>
      <dc:creator>mstjohn_splunk</dc:creator>
      <dc:date>2018-08-28T19:45:49Z</dc:date>
    </item>
  </channel>
</rss>

