<?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: Eval function on a column that has spaces in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Eval-function-on-a-column-that-has-spaces/m-p/19652#M3000</link>
    <description>&lt;P&gt;Just do field extractions without spaces in the field names.&lt;/P&gt;</description>
    <pubDate>Mon, 30 Jul 2012 12:43:46 GMT</pubDate>
    <dc:creator>dmaislin_splunk</dc:creator>
    <dc:date>2012-07-30T12:43:46Z</dc:date>
    <item>
      <title>Eval function on a column that has spaces</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-function-on-a-column-that-has-spaces/m-p/19648#M2996</link>
      <description>&lt;P&gt;Table blah, “has a space” |eval tonumber(“has a space”)/2&lt;/P&gt;

&lt;P&gt;Do you know a way to do the above that works?  In the above, it treats “has a space” as a string rather than the data in the column.  My workaround is:&lt;/P&gt;

&lt;P&gt;table blah, "has a space"|rename “has a space” as blah2|eval tonumber(blah2)/2|rename blah2 “has a space” &lt;/P&gt;

&lt;P&gt;There has to be an easier way.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jul 2012 13:40:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-function-on-a-column-that-has-spaces/m-p/19648#M2996</guid>
      <dc:creator>ttanasovski</dc:creator>
      <dc:date>2012-07-27T13:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: Eval function on a column that has spaces</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-function-on-a-column-that-has-spaces/m-p/19649#M2997</link>
      <description>&lt;P&gt;I would add a field extraction to pull out just the number from either the field or _raw data. If you pull out just a number into a field then Splunk will treat it as a number and you can perform functions on it.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jul 2012 20:30:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-function-on-a-column-that-has-spaces/m-p/19649#M2997</guid>
      <dc:creator>Kate_Lawrence-G</dc:creator>
      <dc:date>2012-07-27T20:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: Eval function on a column that has spaces</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-function-on-a-column-that-has-spaces/m-p/19650#M2998</link>
      <description>&lt;P&gt;So looking at my actual problem, it still stands.  The tonumber is a bit of a red herring.  I didn't actually need to use tonumber.  The problem is that I want to use anything in eval with spaces.  This is an extract, but the column name has a space in it.&lt;/P&gt;

&lt;P&gt;table blah, "has a space"|rename “has a space” as blah2|eval blah2/2|rename blah2 “has a space”&lt;/P&gt;

&lt;P&gt;If I try to do the following, I get an error:&lt;BR /&gt;
table blah, "has a space" |eval "has a space"/2&lt;/P&gt;

&lt;P&gt;How can I do the above without the rename?&lt;/P&gt;</description>
      <pubDate>Sun, 29 Jul 2012 20:51:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-function-on-a-column-that-has-spaces/m-p/19650#M2998</guid>
      <dc:creator>ttanasovski</dc:creator>
      <dc:date>2012-07-29T20:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: Eval function on a column that has spaces</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-function-on-a-column-that-has-spaces/m-p/19651#M2999</link>
      <description>&lt;P&gt;My experience has been that you'll need the rename.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jul 2012 12:39:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-function-on-a-column-that-has-spaces/m-p/19651#M2999</guid>
      <dc:creator>sowings</dc:creator>
      <dc:date>2012-07-30T12:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: Eval function on a column that has spaces</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-function-on-a-column-that-has-spaces/m-p/19652#M3000</link>
      <description>&lt;P&gt;Just do field extractions without spaces in the field names.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Jul 2012 12:43:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-function-on-a-column-that-has-spaces/m-p/19652#M3000</guid>
      <dc:creator>dmaislin_splunk</dc:creator>
      <dc:date>2012-07-30T12:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: Eval function on a column that has spaces</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-function-on-a-column-that-has-spaces/m-p/19653#M3001</link>
      <description>&lt;P&gt;I have found a place where I need this, where the eval statement is happening in something automated.  I tried the {} trick and it didn't work sadly.  Namely --- given a field foo whose value is "fooValue",    &lt;CODE&gt;| eval {foo}=12&lt;/CODE&gt; will create a field called &lt;CODE&gt;fooValue&lt;/CODE&gt; whose value is 12.   Not super widely known, but quite useful.    &lt;/P&gt;

&lt;P&gt;At any rate, from this you might hope that &lt;CODE&gt;{"my field name has spaces"}&lt;/CODE&gt; would work in eval as a syntax to get around the problem, but sadly it doesn't.  There's no error which is odd, but it doesn't end up referencing the field name with the spaces.&lt;/P&gt;</description>
      <pubDate>Sat, 02 Mar 2013 01:11:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-function-on-a-column-that-has-spaces/m-p/19653#M3001</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2013-03-02T01:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: Eval function on a column that has spaces</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-function-on-a-column-that-has-spaces/m-p/19654#M3002</link>
      <description>&lt;P&gt;I found the answer here: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.0/SearchReference/Eval"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.0/SearchReference/Eval&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;You have to use single quotes instead of double quotes when referencing fields inside of eval functions:&lt;/P&gt;

&lt;P&gt;Table blah, “has a space” |eval tonumber('has a space')/2&lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2014 20:13:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-function-on-a-column-that-has-spaces/m-p/19654#M3002</guid>
      <dc:creator>jda258</dc:creator>
      <dc:date>2014-12-23T20:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: Eval function on a column that has spaces</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-function-on-a-column-that-has-spaces/m-p/19655#M3003</link>
      <description>&lt;P&gt;Also tricky is when assigning a result to a field as you need double quotes:&lt;/P&gt;

&lt;P&gt;eval "field with spaces"=round('field with spaces')&lt;/P&gt;</description>
      <pubDate>Tue, 23 Dec 2014 20:15:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-function-on-a-column-that-has-spaces/m-p/19655#M3003</guid>
      <dc:creator>jda258</dc:creator>
      <dc:date>2014-12-23T20:15:03Z</dc:date>
    </item>
  </channel>
</rss>

