<?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 to use calculated fields created using Splunk Web in search? in Knowledge Management</title>
    <link>https://community.splunk.com/t5/Knowledge-Management/How-to-use-calculated-fields-created-using-Splunk-Web-in-search/m-p/329300#M2824</link>
    <description>&lt;P&gt;@indusbull, since your second query is working, seems like issue is with how you have created Calculated field.&lt;/P&gt;

&lt;P&gt;First thing you have to remember is that the field name that you use for Calculated Field will be case sensitive. So as per your second example the field name is actually &lt;CODE&gt;Success&lt;/CODE&gt; and not &lt;CODE&gt;SUCCESS&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Second, you can use &lt;CODE&gt;case()&lt;/CODE&gt; instead of &lt;CODE&gt;if()&lt;/CODE&gt; to set the Success field value to "SUCCESS", if TYPE="S" and do not set the value for any other type i.e. null. So the eval expression would be &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|  eval Success=case(TYPE=="S","SUCCESS")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is how Calculated Field Configuration should look like. Please compare and validate (&lt;CODE&gt;props.conf&lt;/CODE&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[customsource]
EVAL-Success = case(TYPE=="S","SUCCESS")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 12 Apr 2018 19:26:47 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2018-04-12T19:26:47Z</dc:date>
    <item>
      <title>How to use calculated fields created using Splunk Web in search?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-use-calculated-fields-created-using-Splunk-Web-in-search/m-p/329299#M2823</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;
I created a calculated field called "SUCCESS" using Splunk Web on sourcetype. The calculated field eval condition is like if(TYPE="S", "Success", null).  Now I am trying to use this calculated field in my search like below -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=customindex sourcetype=customsource | stats count(SUCCESS) as SuccessCount
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But this returns no results and I know there are events in source that qualifies eval conditions. Not sure what I am doing wrong?&lt;/P&gt;

&lt;P&gt;Before my search used to be like below for ref - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=customindex sourcetype=customsource | eval Success=if(TYPE=="S", "Success", null) | stats count(Success) as SuccessCount
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Apr 2018 17:31:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-use-calculated-fields-created-using-Splunk-Web-in-search/m-p/329299#M2823</guid>
      <dc:creator>indusbull</dc:creator>
      <dc:date>2018-04-12T17:31:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to use calculated fields created using Splunk Web in search?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-use-calculated-fields-created-using-Splunk-Web-in-search/m-p/329300#M2824</link>
      <description>&lt;P&gt;@indusbull, since your second query is working, seems like issue is with how you have created Calculated field.&lt;/P&gt;

&lt;P&gt;First thing you have to remember is that the field name that you use for Calculated Field will be case sensitive. So as per your second example the field name is actually &lt;CODE&gt;Success&lt;/CODE&gt; and not &lt;CODE&gt;SUCCESS&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Second, you can use &lt;CODE&gt;case()&lt;/CODE&gt; instead of &lt;CODE&gt;if()&lt;/CODE&gt; to set the Success field value to "SUCCESS", if TYPE="S" and do not set the value for any other type i.e. null. So the eval expression would be &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|  eval Success=case(TYPE=="S","SUCCESS")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is how Calculated Field Configuration should look like. Please compare and validate (&lt;CODE&gt;props.conf&lt;/CODE&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[customsource]
EVAL-Success = case(TYPE=="S","SUCCESS")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Apr 2018 19:26:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-use-calculated-fields-created-using-Splunk-Web-in-search/m-p/329300#M2824</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-04-12T19:26:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to use calculated fields created using Splunk Web in search?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-use-calculated-fields-created-using-Splunk-Web-in-search/m-p/329301#M2825</link>
      <description>&lt;P&gt;Thanks.  The real issue was with if(). Using cas() solved it.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2018 19:44:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-use-calculated-fields-created-using-Splunk-Web-in-search/m-p/329301#M2825</guid>
      <dc:creator>indusbull</dc:creator>
      <dc:date>2018-04-12T19:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to use calculated fields created using Splunk Web in search?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/How-to-use-calculated-fields-created-using-Splunk-Web-in-search/m-p/329302#M2826</link>
      <description>&lt;P&gt;@indusbull, glad it worked. I am surprised though, as to how your second search worked with &lt;CODE&gt;if()&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Apr 2018 20:00:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/How-to-use-calculated-fields-created-using-Splunk-Web-in-search/m-p/329302#M2826</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-04-12T20:00:42Z</dc:date>
    </item>
  </channel>
</rss>

