<?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 do you use the eval command when the field value contains multiple variables? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-the-eval-command-when-the-field-value-contains/m-p/453259#M128296</link>
    <description>&lt;P&gt;worked like a charm. thanks.&lt;/P&gt;</description>
    <pubDate>Tue, 05 Feb 2019 11:08:10 GMT</pubDate>
    <dc:creator>jacqu3sy</dc:creator>
    <dc:date>2019-02-05T11:08:10Z</dc:date>
    <item>
      <title>How do you use the eval command when the field value contains multiple variables?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-the-eval-command-when-the-field-value-contains/m-p/453256#M128293</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;How do I use the eval statement when the field value could contain multiple variables?&lt;/P&gt;

&lt;P&gt;so for example my field "OS" could be;&lt;/P&gt;

&lt;P&gt;Windows XP&lt;BR /&gt;
Windows 7&lt;BR /&gt;
Windows 10&lt;BR /&gt;
Server 2003&lt;BR /&gt;
Server2008&lt;/P&gt;

&lt;P&gt;I want to use an eval to create two new fields; one for server OS and another for desktop OS&lt;/P&gt;

&lt;P&gt;So something like &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval server=if(OS="Server 2003" OR OS="Server2008")
| eval desktop=if(OS="Windows XP" OR OS="Windows 10")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 10:50:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-the-eval-command-when-the-field-value-contains/m-p/453256#M128293</guid>
      <dc:creator>jacqu3sy</dc:creator>
      <dc:date>2019-02-05T10:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do you use the eval command when the field value contains multiple variables?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-the-eval-command-when-the-field-value-contains/m-p/453257#M128294</link>
      <description>&lt;P&gt;You could use either &lt;CODE&gt;match&lt;/CODE&gt; or &lt;CODE&gt;like&lt;/CODE&gt; as an eval function here ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval is_server = if(like(OS, "Server%"),"1","0")
 | eval is_desktop = if(like(OS, "Windows%"),"1","0")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Like uses a SQL-like wildcard matching. You can get even more flexibility with &lt;CODE&gt;match&lt;/CODE&gt; - which uses regex...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | eval is_server = if(match(OS, "Server\s?[\d]{4}"),"1","0")
 | eval is_desktop = if(like(OS, "Windows"),"1","0")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 10:56:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-the-eval-command-when-the-field-value-contains/m-p/453257#M128294</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2019-02-05T10:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: How do you use the eval command when the field value contains multiple variables?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-the-eval-command-when-the-field-value-contains/m-p/453258#M128295</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Try &lt;CODE&gt;case&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourBaseSearch&amp;gt;
| eval os_type=case(OS == "Windows XP" OR OS == "Windows 7" OR OS == "Windows 10", "desktop", OS == "Server 2003" OR OS == "Server2008", "server")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Feb 2019 10:57:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-the-eval-command-when-the-field-value-contains/m-p/453258#M128295</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2019-02-05T10:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do you use the eval command when the field value contains multiple variables?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-the-eval-command-when-the-field-value-contains/m-p/453259#M128296</link>
      <description>&lt;P&gt;worked like a charm. thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 11:08:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-the-eval-command-when-the-field-value-contains/m-p/453259#M128296</guid>
      <dc:creator>jacqu3sy</dc:creator>
      <dc:date>2019-02-05T11:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do you use the eval command when the field value contains multiple variables?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-the-eval-command-when-the-field-value-contains/m-p/453260#M128297</link>
      <description>&lt;P&gt;Great, you are welcome&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 11:47:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-use-the-eval-command-when-the-field-value-contains/m-p/453260#M128297</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2019-02-05T11:47:23Z</dc:date>
    </item>
  </channel>
</rss>

