<?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 do I create an eval expression for a data model? in Knowledge Management</title>
    <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-create-an-eval-expression-for-a-data-model/m-p/444619#M3940</link>
    <description>&lt;P&gt;i have an expression which i am trying to use for a calculated field, and it is within a data model for web requests. &lt;/P&gt;

&lt;P&gt;the expression is based on HTTP codes with conditions &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (if(status='200', "OKAY"), 
 (if(status&amp;gt;='400', "CLIENT ERROR"), 
 (if(status&amp;gt;='500', "SERVER ERROR"), 
 (if(status&amp;gt;='600', "OTHER"))))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;does not seem to work.. &lt;/P&gt;</description>
    <pubDate>Wed, 24 Oct 2018 14:13:17 GMT</pubDate>
    <dc:creator>danesh_shah</dc:creator>
    <dc:date>2018-10-24T14:13:17Z</dc:date>
    <item>
      <title>How do I create an eval expression for a data model?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-create-an-eval-expression-for-a-data-model/m-p/444619#M3940</link>
      <description>&lt;P&gt;i have an expression which i am trying to use for a calculated field, and it is within a data model for web requests. &lt;/P&gt;

&lt;P&gt;the expression is based on HTTP codes with conditions &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (if(status='200', "OKAY"), 
 (if(status&amp;gt;='400', "CLIENT ERROR"), 
 (if(status&amp;gt;='500', "SERVER ERROR"), 
 (if(status&amp;gt;='600', "OTHER"))))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;does not seem to work.. &lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 14:13:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-do-I-create-an-eval-expression-for-a-data-model/m-p/444619#M3940</guid>
      <dc:creator>danesh_shah</dc:creator>
      <dc:date>2018-10-24T14:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create an eval expression for a data model?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-create-an-eval-expression-for-a-data-model/m-p/444620#M3941</link>
      <description>&lt;P&gt;also tried &lt;BR /&gt;
(case(status&amp;gt;=200,"okay",&lt;BR /&gt;
status&amp;gt;=400,"client error",&lt;BR /&gt;
status&amp;gt;=500,"server error",&lt;BR /&gt;
status&amp;gt;600,"other"))&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 14:15:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-do-I-create-an-eval-expression-for-a-data-model/m-p/444620#M3941</guid>
      <dc:creator>danesh_shah</dc:creator>
      <dc:date>2018-10-24T14:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create an eval expression for a data model?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-create-an-eval-expression-for-a-data-model/m-p/444621#M3942</link>
      <description>&lt;P&gt;just a question, why is there () covering the whole statement? Additionally, what you want to check would be whether those numbers are actually numerical values or not. &lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 14:32:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-do-I-create-an-eval-expression-for-a-data-model/m-p/444621#M3942</guid>
      <dc:creator>MikaJustasACN</dc:creator>
      <dc:date>2018-10-24T14:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create an eval expression for a data model?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-create-an-eval-expression-for-a-data-model/m-p/444622#M3943</link>
      <description>&lt;P&gt;i imagined the whole statement would require to be enclosed in brackets, however i have tried without and it still did not resolve.&lt;/P&gt;

&lt;P&gt;those numbers are numerical as the first line where it says case(status=200, "OKAY" &lt;BR /&gt;
the preview tab reports shows this conversion but the remaining 3 conditions do not seem to resolve the search report for all field values only state to be "OKAY" even if the status code is 400...&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 14:38:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-do-I-create-an-eval-expression-for-a-data-model/m-p/444622#M3943</guid>
      <dc:creator>danesh_shah</dc:creator>
      <dc:date>2018-10-24T14:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create an eval expression for a data model?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-create-an-eval-expression-for-a-data-model/m-p/444623#M3944</link>
      <description>&lt;P&gt;thats only using case, correct? The problem is how case sees it, as soon as it hits first match it stops evaluating. so your status&amp;gt;=200 always correct thus always shows okay and nothing else. &lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 14:44:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-do-I-create-an-eval-expression-for-a-data-model/m-p/444623#M3944</guid>
      <dc:creator>MikaJustasACN</dc:creator>
      <dc:date>2018-10-24T14:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create an eval expression for a data model?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-create-an-eval-expression-for-a-data-model/m-p/444624#M3945</link>
      <description>&lt;P&gt;Thats correct using case only the first line is resolving.&lt;/P&gt;

&lt;P&gt;when tried to use IF the expression kept failing completely although making the correct adjustments for the IF statement.&lt;/P&gt;

&lt;P&gt;which was &lt;/P&gt;

&lt;P&gt;if(status=200, "OKAY", &lt;BR /&gt;
status&amp;gt;=400, "CLIENT ERROR", &lt;BR /&gt;
status&amp;gt;=500, "SERVER ERROR", &lt;BR /&gt;
status&amp;gt;=600, "OTHER")&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 14:52:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-do-I-create-an-eval-expression-for-a-data-model/m-p/444624#M3945</guid>
      <dc:creator>danesh_shah</dc:creator>
      <dc:date>2018-10-24T14:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create an eval expression for a data model?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-create-an-eval-expression-for-a-data-model/m-p/444625#M3946</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;P&gt;case(status&amp;gt;=600,"other",&lt;BR /&gt;
status&amp;gt;=500,"server error",&lt;BR /&gt;
status&amp;gt;=400,"client error",&lt;BR /&gt;
status&amp;gt;=200,"okay")&lt;/P&gt;

&lt;P&gt;never using IF, but again, make sure you use boolean expressions (==, &amp;gt;=,&amp;lt;=) and not assignment (=). Also make sure there is last condition in an IF if nothing matches. Not sure if Splunk enforces it. &lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2018 14:56:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-do-I-create-an-eval-expression-for-a-data-model/m-p/444625#M3946</guid>
      <dc:creator>MikaJustasACN</dc:creator>
      <dc:date>2018-10-24T14:56:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create an eval expression for a data model?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-do-I-create-an-eval-expression-for-a-data-model/m-p/444626#M3947</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/144157"&gt;@danesh_shah&lt;/a&gt;, please try the following run anywhere example. It builds the HTTP Description based on http_status_code provided on Wikipedia: &lt;A href="https://en.wikipedia.org/wiki/List_of_HTTP_status_codes" target="_blank"&gt;https://en.wikipedia.org/wiki/List_of_HTTP_status_codes&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval http_status_code="101,204,200,302,404,502,600"
| makemv http_status_code delim=","
| mvexpand http_status_code
| eval http_status_description=case(match(http_status_code,"^1\d{2}$"),"Informational",
    match(http_status_code,"^2\d{2}$"),"Success",
    match(http_status_code,"^3\d{2}$"),"Redirection",
    match(http_status_code,"^4\d{2}$"),"Client Error",
    match(http_status_code,"^5\d{2}$"),"Server Error",
    true(),"Unknown")
| table http_status_code http_status_description
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:45:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-do-I-create-an-eval-expression-for-a-data-model/m-p/444626#M3947</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T21:45:07Z</dc:date>
    </item>
  </channel>
</rss>

