<?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 extract values from field and use it as column header in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-field-and-use-it-as-column-header/m-p/469274#M132059</link>
    <description>&lt;P&gt;hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/200934"&gt;@egonstep&lt;/a&gt; &lt;BR /&gt;
It is mentioned here but very briefly - looks like the old motto in life of 'mention the really important stuff as sparsely as you can' is being adhered to &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;BR /&gt;
ref - &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.1/SearchReference/Eval" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/7.3.1/SearchReference/Eval&lt;/A&gt;&lt;BR /&gt;
Section :&lt;BR /&gt;
Field names&lt;BR /&gt;
To specify a field name with multiple words, you can either concatenate the words, or use single quotation marks when you specify the name. For example, to specify the field name Account ID you can specify AccountID or 'Account ID'.&lt;/P&gt;

&lt;P&gt;To specify a field name with special characters, such as a period, use single quotation marks. For example, to specify the field name Last.Name use 'Last.Name'.&lt;/P&gt;

&lt;P&gt;You can use the value of another field as the name of the destination field by using curly brackets, { }. For example, if you have an event with the following fields, aName=counter and aValue=1234. Use | eval {aName}=aValue to return counter=1234.&lt;/P&gt;

&lt;P&gt;Basically , what this does is transfer the rows(values) of a column(field) into column headers.&lt;BR /&gt;
so if I run this and you can run this as well as it is since it is on the delivered _audit index&lt;BR /&gt;
 index="_audit" &lt;BR /&gt;
| table action,date_minute&lt;BR /&gt;
I will receive a table with 2 fields action and the date_minute. For some weird reason (and well, this is a bad example) if I want to see the action fields or the date_minute as headers AND have the corresponding values as a sort of pivot as the cells, I can use something like&lt;BR /&gt;
index="_audit" &lt;BR /&gt;
| table action,date_minute&lt;BR /&gt;
| eval {date_minute}=action&lt;BR /&gt;
OR  vice veras that is see my action row values as headers &lt;BR /&gt;
index="_audit" &lt;BR /&gt;
| table action,date_minute&lt;BR /&gt;
| eval {date_minute}=action&lt;BR /&gt;
So any time you see something which talks about transforming row values into column headers , try the curly eval !&lt;BR /&gt;
Lastly, apologize for my first answer which was way beyond wrong, I only got to realize what you wanted after seeing your event snapshot. I believe &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/127939"&gt;@kamlesh_vaghela&lt;/a&gt; (who is one of our most valued members would have come up with a better answer and in a shorter span of time ,if he had a bit of time to devote to this) deserves a 'pat on the back' award &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 02:01:40 GMT</pubDate>
    <dc:creator>Sukisen1981</dc:creator>
    <dc:date>2020-09-30T02:01:40Z</dc:date>
    <item>
      <title>How to extract values from field and use it as column header</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-field-and-use-it-as-column-header/m-p/469267#M132052</link>
      <description>&lt;P&gt;Hello all, how do I retrieve the values from my search and insert in the same row, extracting the values from the field Services, like:&lt;/P&gt;

&lt;P&gt;current search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;search&amp;gt;
| stats sum(FAIL) as Fails, sum(PASS) as Passes, sum(TOTAL_VOLUME) as Total, values(SERVICE) as 
Services by CLIENT
| table CLIENT Fails Passes Total Services
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Results:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;CLIENT   Fails  Passes  Total   Services
ClientA    10      1       11    A
                                 B
                                 C
ClientB     0      1        1    D
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And I need to set the results like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;CLIENT   Fails  Passes  Total   A  B  C  D
ClientA   10      1       11    5  5  1  0
ClientB    0      1        1    0  0  0  1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Example of events:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;DATE_TIME="2019-08-08 00:00:00" CLIENT="ClientA", SERVICE="A", FAIL="0", PASS="1", TOTAL_VOLUME="1"

DATE_TIME="2019-08-08 00:00:00" CLIENT="ClientA", SERVICE="C", FAIL="3", PASS="0", TOTAL_VOLUME="3"

DATE_TIME="2019-08-08 00:00:00" CLIENT="ClientB", SERVICE="D", FAIL="0", PASS="1", TOTAL_VOLUME="1"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2019 19:33:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-field-and-use-it-as-column-header/m-p/469267#M132052</guid>
      <dc:creator>egonstep</dc:creator>
      <dc:date>2019-08-29T19:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract values from field and use it as column header</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-field-and-use-it-as-column-header/m-p/469268#M132053</link>
      <description>&lt;P&gt;| stats sum(fail) as Fails, sum(pass) as Passes, sum(Total_Volume) as Total, count(SERVICE) as &lt;BR /&gt;
 Services by CLIENT,SERVICE |table &lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2019 20:23:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-field-and-use-it-as-column-header/m-p/469268#M132053</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-08-29T20:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract values from field and use it as column header</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-field-and-use-it-as-column-header/m-p/469269#M132054</link>
      <description>&lt;P&gt;Hey Sukisen, thanks for the quick response.&lt;/P&gt;

&lt;P&gt;But didn't worked the way it supposed.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;CLIENT   SERVICE   Services
ClientA       A         5
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So the count is hiding the other services like (B,C, D..etc).&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 11:50:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-field-and-use-it-as-column-header/m-p/469269#M132054</guid>
      <dc:creator>egonstep</dc:creator>
      <dc:date>2019-08-30T11:50:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract values from field and use it as column header</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-field-and-use-it-as-column-header/m-p/469270#M132055</link>
      <description>&lt;P&gt;@egonstep &lt;/P&gt;

&lt;P&gt;Can you please sample events? As per the question what I understood, there are fields &lt;CODE&gt;A ,B, C, D&lt;/CODE&gt;&lt;BR /&gt;
in your events but optional and depends on &lt;CODE&gt;Services&lt;/CODE&gt; fields. Please correct me if I'm wrong.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 12:03:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-field-and-use-it-as-column-header/m-p/469270#M132055</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-08-30T12:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract values from field and use it as column header</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-field-and-use-it-as-column-header/m-p/469271#M132056</link>
      <description>&lt;P&gt;Hey Kamlesh, I updated the question with some sample events.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 12:43:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-field-and-use-it-as-column-header/m-p/469271#M132056</guid>
      <dc:creator>egonstep</dc:creator>
      <dc:date>2019-08-30T12:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract values from field and use it as column header</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-field-and-use-it-as-column-header/m-p/469272#M132057</link>
      <description>&lt;P&gt;hi @egonstep &lt;BR /&gt;
try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  | stats sum(FAIL) as Fails, sum(PASS) as Passes, sum(TOTAL_VOLUME) as Total  by CLIENT,SERVICE
    | fields CLIENT,Fails,Passes,SERVICE,Total| eval {SERVICE}=Total
    | fillnull value=0
    | fields - SERVICE| stats sum(*) by CLIENT
    | rename sum(* as ""*
    | rename *) as *""
    | fields CLIENT,Fails,Passes,Total,*
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Aug 2019 13:57:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-field-and-use-it-as-column-header/m-p/469272#M132057</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-08-30T13:57:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract values from field and use it as column header</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-field-and-use-it-as-column-header/m-p/469273#M132058</link>
      <description>&lt;P&gt;Wow Sukisen, you're the Splunk wizard lol. That's is exactly what I wanted.&lt;/P&gt;

&lt;P&gt;Would you mind explaining how does {} works?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval {SERVICE}=Total
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or if you can suggest any reading material.&lt;/P&gt;

&lt;P&gt;Thanks!!&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 15:05:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-field-and-use-it-as-column-header/m-p/469273#M132058</guid>
      <dc:creator>egonstep</dc:creator>
      <dc:date>2019-08-30T15:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract values from field and use it as column header</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-field-and-use-it-as-column-header/m-p/469274#M132059</link>
      <description>&lt;P&gt;hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/200934"&gt;@egonstep&lt;/a&gt; &lt;BR /&gt;
It is mentioned here but very briefly - looks like the old motto in life of 'mention the really important stuff as sparsely as you can' is being adhered to &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;BR /&gt;
ref - &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.1/SearchReference/Eval" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/7.3.1/SearchReference/Eval&lt;/A&gt;&lt;BR /&gt;
Section :&lt;BR /&gt;
Field names&lt;BR /&gt;
To specify a field name with multiple words, you can either concatenate the words, or use single quotation marks when you specify the name. For example, to specify the field name Account ID you can specify AccountID or 'Account ID'.&lt;/P&gt;

&lt;P&gt;To specify a field name with special characters, such as a period, use single quotation marks. For example, to specify the field name Last.Name use 'Last.Name'.&lt;/P&gt;

&lt;P&gt;You can use the value of another field as the name of the destination field by using curly brackets, { }. For example, if you have an event with the following fields, aName=counter and aValue=1234. Use | eval {aName}=aValue to return counter=1234.&lt;/P&gt;

&lt;P&gt;Basically , what this does is transfer the rows(values) of a column(field) into column headers.&lt;BR /&gt;
so if I run this and you can run this as well as it is since it is on the delivered _audit index&lt;BR /&gt;
 index="_audit" &lt;BR /&gt;
| table action,date_minute&lt;BR /&gt;
I will receive a table with 2 fields action and the date_minute. For some weird reason (and well, this is a bad example) if I want to see the action fields or the date_minute as headers AND have the corresponding values as a sort of pivot as the cells, I can use something like&lt;BR /&gt;
index="_audit" &lt;BR /&gt;
| table action,date_minute&lt;BR /&gt;
| eval {date_minute}=action&lt;BR /&gt;
OR  vice veras that is see my action row values as headers &lt;BR /&gt;
index="_audit" &lt;BR /&gt;
| table action,date_minute&lt;BR /&gt;
| eval {date_minute}=action&lt;BR /&gt;
So any time you see something which talks about transforming row values into column headers , try the curly eval !&lt;BR /&gt;
Lastly, apologize for my first answer which was way beyond wrong, I only got to realize what you wanted after seeing your event snapshot. I believe &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/127939"&gt;@kamlesh_vaghela&lt;/a&gt; (who is one of our most valued members would have come up with a better answer and in a shorter span of time ,if he had a bit of time to devote to this) deserves a 'pat on the back' award &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:01:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-field-and-use-it-as-column-header/m-p/469274#M132059</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2020-09-30T02:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract values from field and use it as column header</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-field-and-use-it-as-column-header/m-p/469275#M132060</link>
      <description>&lt;P&gt;Oh, I see, I think I got it, just need to practice more lol. But thanks Sukisen for the responses and explanations. It helped a lot.&lt;/P&gt;

&lt;P&gt;Just to let you know or maybe help someone in the future. My current code is like this, (showing all the values as a percentage by time as well):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;search&amp;gt;
| bin _time span=1h
| stats sum(FAIL) as "Total Fails" sum(PASS) as "Total Passes" sum(TOTAL_VOLUME) as Total by 
CLIENT, _time, SERVICE
| fields CLIENT, "Total Fails", "Total Passes", SERVICE, Total,  _time
| eval {SERVICE}=Total
| fillnull value=0
| fields - SERVICE
| stats sum(*) by CLIENT, _time
| rename sum(* as ""*
| rename *) as *%""
| rename "Total %" as Total
| eval "Total Fails"='Total Fails%', "Total Passes"='Total Passes%'
| fields _time, CLIENT, *, "Total Passes", "Total Fails", Total
| rename _time AS "Date:Hour"
| convert timeformat="%m/%d:%H" ctime("Date:Hour")
| sort -"Total Passes"
| head 5
| foreach *%
    [eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=round(('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'/Total)*100,2)]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thank you again!&lt;/P&gt;</description>
      <pubDate>Fri, 30 Aug 2019 17:09:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-field-and-use-it-as-column-header/m-p/469275#M132060</guid>
      <dc:creator>egonstep</dc:creator>
      <dc:date>2019-08-30T17:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract values from field and use it as column header</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-field-and-use-it-as-column-header/m-p/679327#M232225</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/182782"&gt;@Sukisen1981&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;Your Query helped me !! Thank you.&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I had a small question. I have a similar Query which I wanted to show By Month&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;CLIENT   Fails  Passes  Total   MonthClientA   10      1       11     jan
ClientB    0      1        1    &amp;nbsp;mar&lt;BR /&gt;CliectC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;11&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;9        20    feb&lt;/PRE&gt;&lt;P&gt;&lt;FONT face="Menlo, Monaco, Consolas, Courier New, monospace" color="#c7254e"&gt;&lt;SPAN&gt;So I had tried your query and i got the below results...&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/FONT&gt;I used this for month&amp;nbsp;&lt;STRONG&gt;| eval Month=strftime(_time, "%B")&lt;BR /&gt;&lt;/STRONG&gt;But I wanted to get the latest month first so on like mar feb jan&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;CLIENT   Fails  Passes  Total   MAR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;JAN&amp;nbsp;&amp;nbsp;&amp;nbsp;FEBClientA   10      1       11     0       5    0
ClientB    0      1        1    &amp;nbsp;2      11    0&lt;BR /&gt;CliectC&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;11&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;9        20    0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;19&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2024 17:59:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-field-and-use-it-as-column-header/m-p/679327#M232225</guid>
      <dc:creator>Naa_Win</dc:creator>
      <dc:date>2024-03-01T17:59:11Z</dc:date>
    </item>
  </channel>
</rss>

