<?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 get eval values from two fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-eval-values-from-two-fields/m-p/423498#M121532</link>
    <description>&lt;P&gt;Ahh, I see!&lt;/P&gt;

&lt;P&gt;If I am understanding correctly, would using&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...|timechart count(statusCategory)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;instead of&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...|timechart count by statusCategory
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;in one of my previous examples do the trick?&lt;/P&gt;</description>
    <pubDate>Fri, 14 Jun 2019 20:27:13 GMT</pubDate>
    <dc:creator>rbechtold</dc:creator>
    <dc:date>2019-06-14T20:27:13Z</dc:date>
    <item>
      <title>How to get eval values from two fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-eval-values-from-two-fields/m-p/423495#M121529</link>
      <description>&lt;P&gt;My current search is this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="x | timechart count(eval(statusCategory="B")) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to add one more statusCategory="C" and tried making like - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="x | timechart count(eval(statusCategory="B" OR statusCategory="C" ))  but it do not work
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Jun 2019 19:49:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-eval-values-from-two-fields/m-p/423495#M121529</guid>
      <dc:creator>rashi83</dc:creator>
      <dc:date>2019-06-14T19:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to get eval values from two fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-eval-values-from-two-fields/m-p/423496#M121530</link>
      <description>&lt;P&gt;Hi Rashi83,&lt;/P&gt;

&lt;P&gt;Does this work?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| index=x 
| search statusCategory="B" OR statusCategory="C" 
| timechart count by statusCategory
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Alternatively, if you need to define the "statusCategory" before the timechart, you can use:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| index=x
| eval statusCategory=if(statusCategory="B_string", "B", if(statusCategory="C_string", "C", null))
| where isnotnull(statusCategory)
| timechart count by statusCategory
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Jun 2019 19:53:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-eval-values-from-two-fields/m-p/423496#M121530</guid>
      <dc:creator>rbechtold</dc:creator>
      <dc:date>2019-06-14T19:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to get eval values from two fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-eval-values-from-two-fields/m-p/423497#M121531</link>
      <description>&lt;P&gt;Thanks, but I need to show the sum up value of statusCategory =A and statusCategory=B while doing visualization as single value. &lt;/P&gt;

&lt;P&gt;This yields correct value but not the sumup value.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 20:19:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-eval-values-from-two-fields/m-p/423497#M121531</guid>
      <dc:creator>rashi83</dc:creator>
      <dc:date>2019-06-14T20:19:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to get eval values from two fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-eval-values-from-two-fields/m-p/423498#M121532</link>
      <description>&lt;P&gt;Ahh, I see!&lt;/P&gt;

&lt;P&gt;If I am understanding correctly, would using&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...|timechart count(statusCategory)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;instead of&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...|timechart count by statusCategory
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;in one of my previous examples do the trick?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 20:27:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-eval-values-from-two-fields/m-p/423498#M121532</guid>
      <dc:creator>rbechtold</dc:creator>
      <dc:date>2019-06-14T20:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to get eval values from two fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-eval-values-from-two-fields/m-p/423499#M121533</link>
      <description>&lt;P&gt;Thank you so much...I was working more on this query and was trying to get percentage of "Pass" . Pass % will include  - statusCategory="Pass" and statusCategory="NearPass" &lt;/P&gt;

&lt;P&gt;index=x | search statusCategory="Pass" OR statusCategory="NearPass" | stats count(statusCategory) as "Pass" | stats count(eval(statusCategory=="Fail")) as "Fail" by region &lt;BR /&gt;
 | addtotals&lt;BR /&gt;
| foreach Compliant, NonCompliant  [| eval "&amp;lt;&amp;gt; %"=round((&amp;lt;&amp;gt;/Total)&lt;EM&gt;100,2)] |  sort - "Pass %" | table region "&lt;/EM&gt; %" | rename region as Region&lt;/P&gt;

&lt;P&gt;But it fails to recognize count of  statusCategory=Fail&lt;BR /&gt;
How can this be modified?&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2019 15:27:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-eval-values-from-two-fields/m-p/423499#M121533</guid>
      <dc:creator>rashi83</dc:creator>
      <dc:date>2019-06-17T15:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to get eval values from two fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-eval-values-from-two-fields/m-p/423500#M121534</link>
      <description>&lt;P&gt;@rashi83 to get total of fail, pass , nearpass use below&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=x | stats count(eval(statusCategory="Pass")) as "Pass", count(eval(statusCategory="NearPass")) as NearPass ,count(eval(statusCategory=="Fail")) as "Fail" by region  | eval Pass=Pass + NearPass&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2019 15:44:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-eval-values-from-two-fields/m-p/423500#M121534</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2019-06-17T15:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to get eval values from two fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-eval-values-from-two-fields/m-p/423501#M121535</link>
      <description>&lt;P&gt;Doesn't work VIjeta&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2019 16:04:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-eval-values-from-two-fields/m-p/423501#M121535</guid>
      <dc:creator>rashi83</dc:creator>
      <dc:date>2019-06-17T16:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to get eval values from two fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-eval-values-from-two-fields/m-p/423502#M121536</link>
      <description>&lt;P&gt;What results do you get?&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2019 17:54:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-eval-values-from-two-fields/m-p/423502#M121536</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2019-06-17T17:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to get eval values from two fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-eval-values-from-two-fields/m-p/423503#M121537</link>
      <description>&lt;P&gt;Hello again rashi! No problem at all, it is my intention to help out however I can.&lt;/P&gt;

&lt;P&gt;The reason it fails to recognize count of statusCategory="Fail" is because the search pipe and the stats pipe removes all instances of fail statuses from the data. Let's try to fix that!&lt;/P&gt;

&lt;P&gt;I'm operating under the assumption that we're working with these two fields for this search: &lt;BR /&gt;
1. statusCategory&lt;BR /&gt;
2. region&lt;/P&gt;

&lt;P&gt;Is this correct? The reason I'm asking is because I see a "Compliant" field and a "NonCompliant" field in the foreach command, and I'm not sure how they come into play.&lt;/P&gt;

&lt;P&gt;That said, if we are just looking for a "Pass %" by region, the query below &lt;EM&gt;should&lt;/EM&gt; work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|index = x
| eval PassCheck = if(statusCategory="Pass", 1, if(statusCategory="NearPass", 1, 0))
| eval FailCheck = if(PassCheck=0, 1, 0)
| stats sum(FailCheck) AS Fail sum(PassCheck) AS Pass  by region
| eval total_by_area = Fail + Pass
| eval area_percent = round((Pass / total_by_area),2) *100
| table region area_percent
| sort - area_percent
| rename area_percent AS "Pass %", region AS Region
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if anything goes wrong, or if anything doesn't make sense!&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2019 19:27:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-eval-values-from-two-fields/m-p/423503#M121537</guid>
      <dc:creator>rbechtold</dc:creator>
      <dc:date>2019-06-17T19:27:45Z</dc:date>
    </item>
  </channel>
</rss>

