<?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 case not evaluating fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-is-eval-case-not-evaluating-fields/m-p/651284#M225167</link>
    <description>&lt;P&gt;First, note that screenshots are very unfavorable for volunteers. &amp;nbsp;Please use text for illustration wherever possible.&lt;/P&gt;&lt;P&gt;Secondly, SPL interprets bare strings on the right-hand side (evaluation expressions) as field names. &amp;nbsp;To match strings, you need to quote them properly.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=core_ct_report_*
| where (report_model = "cfgHT802")
| eval brand=case(report_model=="cfgHT802", grandstream)
| eval brand2=case(like(report_model, "cfgHT802"), grandstream)
| eval brand3=case(like(report_model, "cfg%"), grandstream)
| table report_model brand brand2 brand3&lt;/LI-CODE&gt;</description>
    <pubDate>Thu, 20 Jul 2023 11:47:02 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2023-07-20T11:47:02Z</dc:date>
    <item>
      <title>Why is eval case not evaluating fields?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-eval-case-not-evaluating-fields/m-p/651269#M225165</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i have a field with the models, like below, and with this info i want to define a new field like brand.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lemospt_0-1689847454131.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/26360i7369FDBC9C98F97B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lemospt_0-1689847454131.png" alt="lemospt_0-1689847454131.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;i tried different approaches but can't get brand field populated, below a test search with different case, none works but where clause works well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;index=core_ct_report_*&lt;BR /&gt;| where (report_model = "cfgHT802")&lt;BR /&gt;| eval brand=case(report_model=cfgHT802, grandstream)&lt;BR /&gt;| eval brand2=case(like(report_model, cfgHT802), grandstream)&lt;BR /&gt;| eval brand3=case(like(report_model, "cfg%"), grandstream)&lt;BR /&gt;| table report_model brand brand2 brand3&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lemospt_1-1689847761965.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/26361iCF313A77DBDF340E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lemospt_1-1689847761965.png" alt="lemospt_1-1689847761965.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;what is wrong?&lt;/P&gt;
&lt;P&gt;What i need is something like this,&lt;/P&gt;
&lt;P&gt;| eval brand3=case(like(report_model, "cfg%"), grandstream, ...)&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 19:32:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-eval-case-not-evaluating-fields/m-p/651269#M225165</guid>
      <dc:creator>lemospt</dc:creator>
      <dc:date>2023-07-20T19:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: eval case not evaluating fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-eval-case-not-evaluating-fields/m-p/651284#M225167</link>
      <description>&lt;P&gt;First, note that screenshots are very unfavorable for volunteers. &amp;nbsp;Please use text for illustration wherever possible.&lt;/P&gt;&lt;P&gt;Secondly, SPL interprets bare strings on the right-hand side (evaluation expressions) as field names. &amp;nbsp;To match strings, you need to quote them properly.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=core_ct_report_*
| where (report_model = "cfgHT802")
| eval brand=case(report_model=="cfgHT802", grandstream)
| eval brand2=case(like(report_model, "cfgHT802"), grandstream)
| eval brand3=case(like(report_model, "cfg%"), grandstream)
| table report_model brand brand2 brand3&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 20 Jul 2023 11:47:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-eval-case-not-evaluating-fields/m-p/651284#M225167</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-07-20T11:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: eval case not evaluating fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-eval-case-not-evaluating-fields/m-p/651286#M225169</link>
      <description>&lt;P&gt;What is grandstream? If it is a field with content, then at least brand3 should have worked. If it is supposed to be a string, then it needs to be quoted (as do the other strings&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval brand=case(report_model="cfgHT802", "grandstream")
| eval brand2=case(like(report_model, "cfgHT802"), "grandstream")
| eval brand3=case(like(report_model, "cfg%"), "grandstream")&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 20 Jul 2023 11:52:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-eval-case-not-evaluating-fields/m-p/651286#M225169</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-07-20T11:52:41Z</dc:date>
    </item>
    <item>
      <title>Re: eval case not evaluating fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-eval-case-not-evaluating-fields/m-p/651362#M225193</link>
      <description>&lt;P&gt;Thanks both for the inputs&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the problem is the missing double quotes on the true condition like&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;said.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 17:34:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-eval-case-not-evaluating-fields/m-p/651362#M225193</guid>
      <dc:creator>lemospt</dc:creator>
      <dc:date>2023-07-20T17:34:37Z</dc:date>
    </item>
  </channel>
</rss>

