<?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 How can I average a dynamic column created using eval {Field}=Value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-average-a-dynamic-column-created-using-eval-Field/m-p/220101#M64702</link>
    <description>&lt;P&gt;I would like to display some data that has columns based on dynamic data from the search results.&lt;BR /&gt;
e.g. Assuming I have a query to calculate which two servers have the most users logging into them. I can write a query to give me the data in the form of: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Date | ServerWithMostLogins |  ServerWithSecondToMostLogins
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, rather than calling the columns &lt;CODE&gt;ServerWithMostLogins&lt;/CODE&gt;, I'd rename the column to the server's name.&lt;BR /&gt;
I know I can use something like &lt;CODE&gt;| eval {ServerName}&lt;/CODE&gt; but then I don't think I would be able to run &lt;CODE&gt;stats&lt;/CODE&gt; over that column.&lt;BR /&gt;
Is this possible?&lt;/P&gt;

&lt;P&gt;Edit, for example, say I have this data in my search result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Date=Today UserName=user1 ServerLoggedInto=Server23
Date=Today UserName=user45 ServerLoggedInto=Server33
Date=Today UserName=user11 ServerLoggedInto=Server23
Date=Today UserName=user11 ServerLoggedInto=Server23
etc
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I would like is to display which 2 servers have the most logins:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| Date    | Server23 | Server 33 |
+---------+----------+-----------+
| Today   | 3        | 1         |
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get most of this, the thing currently stumping me is how to get the ServerName as the column name.&lt;/P&gt;</description>
    <pubDate>Thu, 05 Nov 2015 20:23:39 GMT</pubDate>
    <dc:creator>chustar</dc:creator>
    <dc:date>2015-11-05T20:23:39Z</dc:date>
    <item>
      <title>How can I average a dynamic column created using eval {Field}=Value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-average-a-dynamic-column-created-using-eval-Field/m-p/220101#M64702</link>
      <description>&lt;P&gt;I would like to display some data that has columns based on dynamic data from the search results.&lt;BR /&gt;
e.g. Assuming I have a query to calculate which two servers have the most users logging into them. I can write a query to give me the data in the form of: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Date | ServerWithMostLogins |  ServerWithSecondToMostLogins
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, rather than calling the columns &lt;CODE&gt;ServerWithMostLogins&lt;/CODE&gt;, I'd rename the column to the server's name.&lt;BR /&gt;
I know I can use something like &lt;CODE&gt;| eval {ServerName}&lt;/CODE&gt; but then I don't think I would be able to run &lt;CODE&gt;stats&lt;/CODE&gt; over that column.&lt;BR /&gt;
Is this possible?&lt;/P&gt;

&lt;P&gt;Edit, for example, say I have this data in my search result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Date=Today UserName=user1 ServerLoggedInto=Server23
Date=Today UserName=user45 ServerLoggedInto=Server33
Date=Today UserName=user11 ServerLoggedInto=Server23
Date=Today UserName=user11 ServerLoggedInto=Server23
etc
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I would like is to display which 2 servers have the most logins:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| Date    | Server23 | Server 33 |
+---------+----------+-----------+
| Today   | 3        | 1         |
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get most of this, the thing currently stumping me is how to get the ServerName as the column name.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2015 20:23:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-average-a-dynamic-column-created-using-eval-Field/m-p/220101#M64702</guid>
      <dc:creator>chustar</dc:creator>
      <dc:date>2015-11-05T20:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: How can I average a dynamic column created using eval {Field}=Value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-average-a-dynamic-column-created-using-eval-Field/m-p/220102#M64703</link>
      <description>&lt;P&gt;Can you expand on what the table you have looks like and what the table you want looks like ?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2015 20:40:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-average-a-dynamic-column-created-using-eval-Field/m-p/220102#M64703</guid>
      <dc:creator>aljohnson_splun</dc:creator>
      <dc:date>2015-11-05T20:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: How can I average a dynamic column created using eval {Field}=Value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-average-a-dynamic-column-created-using-eval-Field/m-p/220103#M64704</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | chart count over host | addtotals col=t row=f | fillnull value="TOTAL" | sort 3 - count | eval dummy="dummy" | chart first(count) AS count over dummy by host | fields - dummy
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Nov 2015 20:46:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-average-a-dynamic-column-created-using-eval-Field/m-p/220103#M64704</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-11-05T20:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: How can I average a dynamic column created using eval {Field}=Value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-average-a-dynamic-column-created-using-eval-Field/m-p/220104#M64705</link>
      <description>&lt;P&gt;Added more information.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Nov 2015 20:55:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-average-a-dynamic-column-created-using-eval-Field/m-p/220104#M64705</guid>
      <dc:creator>chustar</dc:creator>
      <dc:date>2015-11-05T20:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: How can I average a dynamic column created using eval {Field}=Value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-average-a-dynamic-column-created-using-eval-Field/m-p/220105#M64706</link>
      <description>&lt;P&gt;Given your clarification, this would be better (you must run timepicker on some subsection of &lt;CODE&gt;Today&lt;/CODE&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats count BY host | addtotals col=t row=f | fillnull value="TOTAL" | sort 3 - count | eval Date="Today" | chart first(count) AS count over Date BY host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Nov 2015 21:07:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-average-a-dynamic-column-created-using-eval-Field/m-p/220105#M64706</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-11-05T21:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: How can I average a dynamic column created using eval {Field}=Value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-average-a-dynamic-column-created-using-eval-Field/m-p/220106#M64707</link>
      <description>&lt;P&gt;Thanks, I'll try this&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 17:49:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-average-a-dynamic-column-created-using-eval-Field/m-p/220106#M64707</guid>
      <dc:creator>chustar</dc:creator>
      <dc:date>2015-11-06T17:49:10Z</dc:date>
    </item>
    <item>
      <title>Re: How can I average a dynamic column created using eval {Field}=Value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-average-a-dynamic-column-created-using-eval-Field/m-p/220107#M64708</link>
      <description>&lt;P&gt;Thanks for the suggestion. Your answer led me in the right direction. &lt;BR /&gt;
The main important thing was learning that &lt;CODE&gt;stats&lt;/CODE&gt; and &lt;CODE&gt;chart&lt;/CODE&gt; may look identical, but they are very different.&lt;/P&gt;

&lt;P&gt;I also used information from this answer as well: &lt;A href="https://answers.splunk.com/answers/506/split-by-by-clause-of-chart-only-takes-2-dimensions-we-want-3.html#answer-507"&gt;https://answers.splunk.com/answers/506/split-by-by-clause-of-chart-only-takes-2-dimensions-we-want-3.html#answer-507&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2015 20:25:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-average-a-dynamic-column-created-using-eval-Field/m-p/220107#M64708</guid>
      <dc:creator>chustar</dc:creator>
      <dc:date>2015-11-06T20:25:17Z</dc:date>
    </item>
  </channel>
</rss>

