<?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 Why is statement not returning expected results when counting events by &amp;quot;UserAgent&amp;quot; field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-is-statement-not-returning-expected-results-when-counting/m-p/659083#M227611</link>
    <description>&lt;P&gt;Hello&lt;BR /&gt;I'm trying to count events by field called "UserAgent"&lt;BR /&gt;If im searching for the events without any calculated field im getting results from different UserAgents&lt;BR /&gt;But once im using eval, I don't get the expected results&lt;BR /&gt;For example:&lt;BR /&gt;I've tried this eval and im getting only "android" also im searching for "ios" only with&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;"ContextData.UserAgent"=*ios*&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;as part of my query&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| eval UserAgent = if("ContextData.UserAgent"="*ios*","ios","android")&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;what im doing wrong ?&lt;/P&gt;</description>
    <pubDate>Fri, 29 Sep 2023 15:50:07 GMT</pubDate>
    <dc:creator>SplunkySplunk</dc:creator>
    <dc:date>2023-09-29T15:50:07Z</dc:date>
    <item>
      <title>Why is statement not returning expected results when counting events by "UserAgent" field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-statement-not-returning-expected-results-when-counting/m-p/659083#M227611</link>
      <description>&lt;P&gt;Hello&lt;BR /&gt;I'm trying to count events by field called "UserAgent"&lt;BR /&gt;If im searching for the events without any calculated field im getting results from different UserAgents&lt;BR /&gt;But once im using eval, I don't get the expected results&lt;BR /&gt;For example:&lt;BR /&gt;I've tried this eval and im getting only "android" also im searching for "ios" only with&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;"ContextData.UserAgent"=*ios*&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;as part of my query&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| eval UserAgent = if("ContextData.UserAgent"="*ios*","ios","android")&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;what im doing wrong ?&lt;/P&gt;</description>
      <pubDate>Fri, 29 Sep 2023 15:50:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-statement-not-returning-expected-results-when-counting/m-p/659083#M227611</guid>
      <dc:creator>SplunkySplunk</dc:creator>
      <dc:date>2023-09-29T15:50:07Z</dc:date>
    </item>
    <item>
      <title>Re: if statement not returning expected results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-statement-not-returning-expected-results-when-counting/m-p/659084#M227612</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/226206"&gt;@SplunkySplunk&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;the issue is that sometimes, having special chars (as dot) in the field names the eval command fails, use rename and it will work:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rename ContextData.UserAgent AS ContextData_UserAgent
| eval UserAgent = if("ContextData_UserAgent"="*ios*","ios","android")&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 29 Sep 2023 14:11:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-statement-not-returning-expected-results-when-counting/m-p/659084#M227612</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-09-29T14:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: if statement not returning expected results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-statement-not-returning-expected-results-when-counting/m-p/659086#M227613</link>
      <description>&lt;P&gt;A couple of things wrong - field names should be in single quotes not double quotes when on the right hand side of the evaluation - equalities don't work with *, that's just for search filters, try match()&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval UserAgent = if(match('ContextData.UserAgent',"ios"),"ios","android")&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 29 Sep 2023 14:29:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-statement-not-returning-expected-results-when-counting/m-p/659086#M227613</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-09-29T14:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: if statement not returning expected results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-statement-not-returning-expected-results-when-counting/m-p/659176#M227635</link>
      <description>&lt;P&gt;Thanks !&lt;/P&gt;</description>
      <pubDate>Sat, 30 Sep 2023 12:07:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-statement-not-returning-expected-results-when-counting/m-p/659176#M227635</guid>
      <dc:creator>sarit_s</dc:creator>
      <dc:date>2023-09-30T12:07:51Z</dc:date>
    </item>
  </channel>
</rss>

