<?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: Error in 'eval' command: The expression is malformed. Expected IN. in Monitoring Splunk</title>
    <link>https://community.splunk.com/t5/Monitoring-Splunk/Error-in-eval-command-The-expression-is-malformed-Expected-IN/m-p/634045#M9386</link>
    <description>&lt;P&gt;Sure, Thank you&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp; for the help !!!&lt;/P&gt;</description>
    <pubDate>Fri, 10 Mar 2023 11:23:31 GMT</pubDate>
    <dc:creator>Nafees</dc:creator>
    <dc:date>2023-03-10T11:23:31Z</dc:date>
    <item>
      <title>Error in 'eval' command: The expression is malformed. Expected IN.</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/Error-in-eval-command-The-expression-is-malformed-Expected-IN/m-p/634025#M9381</link>
      <description>&lt;P&gt;Hello People,&lt;/P&gt;&lt;P&gt;I am trying to run below splunk query,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;base search |&amp;nbsp;rename msg.message as "message", msg.customer as "customer" | eval Total_Count = 1, Total_Success = if(where isnull( msg.errorCode),"1","0"), Total_Error = if(where isnotnull( msg.errorCode),"1","0") | fields Total_Count,Total_Success,Total_Error,message,customer | stats sum(Total_Count) as Total, sum(Total_Success) as Success, sum(Total_Error) as Error | eval successRate = ((Success/Total)*100)."%" | stats Total, Success, successRate by customer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and I am getting below error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error in 'eval' command: The expression is malformed. Expected IN.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone please let me know what am I doing wrong here? Thanks !!!&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 08:47:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/Error-in-eval-command-The-expression-is-malformed-Expected-IN/m-p/634025#M9381</guid>
      <dc:creator>Nafees</dc:creator>
      <dc:date>2023-03-10T08:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: Error in 'eval' command: The expression is malformed. Expected IN.</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/Error-in-eval-command-The-expression-is-malformed-Expected-IN/m-p/634031#M9382</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/254650"&gt;@Nafees&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;probably the error is in&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Total_Success = if(where isnull( msg.errorCode),"1","0"), 
Total_Error = if(where isnotnull( msg.errorCode),"1","0") &lt;/LI-CODE&gt;&lt;P&gt;you cannot use where isnull,&amp;nbsp;&lt;/P&gt;&lt;P&gt;please try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;base search 
| rename 
   msg.message as "message", 
   msg.customer as "customer" 
| eval 
   Total_Count = 1, 
   Total_Success = if(isnull(msg.errorCode),"1","0"), 
   Total_Error = if(isnotnull(msg.errorCode),"1","0") 
| fields 
   Total_Count,
   Total_Success,
   Total_Error,
   message,
   customer 
| stats 
   sum(Total_Count) as Total, 
   sum(Total_Success) as Success, 
   sum(Total_Error) as Error 
| eval successRate = ((Success/Total)*100)."%" 
| stats 
   Total, 
   Success, 
   successRate 
   BY customer&lt;/LI-CODE&gt;&lt;P&gt;then isn't so clear the sense of Total_Count=1 and then sum(Total_Count) that's always 1, for this reason I leaved it, but I don't understand it!&lt;/P&gt;&lt;P&gt;then you could put the the conditions in the stats command:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;base search 
| rename 
   msg.message AS "message", 
   msg.customer AS "customer"
   msg.errorCode AS errorCode 
| eval 
   Total_Count = 1, 
| stats 
   sum(Total_Count) as Total, 
   count(eval(isnull(msg.errorCode)) AS Success, 
   count(eval(isnotnull(msg.errorCode)) AS Error 
   BY customer
| eval successRate = ((Success/Total)*100)."%" &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 09:22:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/Error-in-eval-command-The-expression-is-malformed-Expected-IN/m-p/634031#M9382</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-03-10T09:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: Error in 'eval' command: The expression is malformed. Expected IN.</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/Error-in-eval-command-The-expression-is-malformed-Expected-IN/m-p/634039#M9383</link>
      <description>&lt;P&gt;Thank You so much&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp; for the response.&lt;/P&gt;&lt;P&gt;Actually what I am trying to do is, when the base search matches, the&amp;nbsp;&lt;SPAN&gt;Total_Count should always get a value, basically here I want to count the total number of events and then the&amp;nbsp;Total_Success and&amp;nbsp;Total_Error should only be counted if their respective conditions are true. And then I want to calculate the rate of success by putting the event counts. Basically what I want to do it something like this&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(total success events/total events)*100&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;that is the reason I gave "1"s to all the events and then sum it up at the last to get the total event count. That is the reason I gave &lt;SPAN&gt;Total_Count a "1" for each event, and then I applied a sum for that to get the total events count.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But I think this approach is not correct right?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I think the solution which you provided at the last answers this question and I can write my query as follows&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;base search 
| rename 
   msg.message AS "message", 
   msg.customer AS "customer"  
| stats 
   count as Total, 
   count(eval(isnull(msg.errorCode)) AS Success, 
   count(eval(isnotnull(msg.errorCode)) AS Error 
   BY customer
| eval successRate = ((Success/Total)*100)."%" &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if my understanding is correct?&lt;/P&gt;&lt;P&gt;also, for success events, the msg.errorCode field will not come in the logs and it will come only for the error event logs. So I want to count an event as Success if the msg.errorCode field is not coming and as Error if its coming.&lt;/P&gt;&lt;P&gt;Hopelully, my logic of using "isnull" and "isnotnull" is correct in this case?&lt;/P&gt;&lt;P&gt;Please clarify and Thank you so much again for response and clearing my doubts. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 10:47:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/Error-in-eval-command-The-expression-is-malformed-Expected-IN/m-p/634039#M9383</guid>
      <dc:creator>Nafees</dc:creator>
      <dc:date>2023-03-10T10:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: Error in 'eval' command: The expression is malformed. Expected IN.</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/Error-in-eval-command-The-expression-is-malformed-Expected-IN/m-p/634043#M9384</link>
      <description>&lt;P&gt;The error is not about logic but about syntax.&lt;/P&gt;&lt;P&gt;if() needs a function returning a boolean value or a composite condition using boolean operators. If you just want to do &lt;EM&gt;if(isnull(something), something, something)&lt;/EM&gt;, you don't insert additional &lt;EM&gt;where&lt;/EM&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 11:20:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/Error-in-eval-command-The-expression-is-malformed-Expected-IN/m-p/634043#M9384</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-03-10T11:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: Error in 'eval' command: The expression is malformed. Expected IN.</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/Error-in-eval-command-The-expression-is-malformed-Expected-IN/m-p/634044#M9385</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/254650"&gt;@Nafees&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;it seems to be correct, but you are the only that can validate results.&lt;/P&gt;&lt;P&gt;Tell me if I can help you more, otherwise, please accept my anser for the other people of Community.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;P.S.: Karma Points are appreciated &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 11:20:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/Error-in-eval-command-The-expression-is-malformed-Expected-IN/m-p/634044#M9385</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-03-10T11:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Error in 'eval' command: The expression is malformed. Expected IN.</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/Error-in-eval-command-The-expression-is-malformed-Expected-IN/m-p/634045#M9386</link>
      <description>&lt;P&gt;Sure, Thank you&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp; for the help !!!&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 11:23:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/Error-in-eval-command-The-expression-is-malformed-Expected-IN/m-p/634045#M9386</guid>
      <dc:creator>Nafees</dc:creator>
      <dc:date>2023-03-10T11:23:31Z</dc:date>
    </item>
    <item>
      <title>Re: Error in 'eval' command: The expression is malformed. Expected IN.</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/Error-in-eval-command-The-expression-is-malformed-Expected-IN/m-p/634046#M9387</link>
      <description>&lt;P&gt;Sure&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;, thank you for your help !!!&lt;/P&gt;</description>
      <pubDate>Fri, 10 Mar 2023 11:24:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/Error-in-eval-command-The-expression-is-malformed-Expected-IN/m-p/634046#M9387</guid>
      <dc:creator>Nafees</dc:creator>
      <dc:date>2023-03-10T11:24:07Z</dc:date>
    </item>
  </channel>
</rss>

