<?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: pass case statement result to search string in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309602#M175004</link>
    <description>&lt;P&gt;Thanks.  Will try.  My current query pulls Resolution Time comparison.  But If I pass in search I get no results found&lt;/P&gt;</description>
    <pubDate>Tue, 04 Apr 2017 08:57:21 GMT</pubDate>
    <dc:creator>k_harini</dc:creator>
    <dc:date>2017-04-04T08:57:21Z</dc:date>
    <item>
      <title>pass case statement result to search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309598#M175000</link>
      <description>&lt;P&gt;I have tokens coming from drilldown&lt;BR /&gt;
index="test" | eval res_time = case( "PRIORITY CODE" == "1"  ,"Resolution Time &amp;lt;=120",1=1,"Resolution Time &amp;lt;2880")| table res_time&lt;/P&gt;

&lt;P&gt;Here res_time here generates value. But i want to pass this to search and retrieve the table. if i pass this to search its not working. May be due to quotes issue. Not sure..  Please help&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Harini&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 13:31:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309598#M175000</guid>
      <dc:creator>k_harini</dc:creator>
      <dc:date>2020-09-29T13:31:49Z</dc:date>
    </item>
    <item>
      <title>Re: pass case statement result to search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309599#M175001</link>
      <description>&lt;P&gt;Do you have this field "Resolution Time"? If you want to calculate it, "Resolution Time" &amp;lt;=120 and "Resolution Time" &amp;lt;2880&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 08:38:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309599#M175001</guid>
      <dc:creator>gfreitas</dc:creator>
      <dc:date>2017-04-04T08:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: pass case statement result to search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309600#M175002</link>
      <description>&lt;P&gt;[Updated Answer] Since your search filter is being set on clicking of a cell in a table, one of the ways to set required search query filter would be to perform &lt;STRONG&gt;eval&lt;/STRONG&gt; at the table &lt;STRONG&gt;drilldown&lt;/STRONG&gt; event itself.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    &amp;lt;drilldown&amp;gt;
      &amp;lt;eval token="res_time"&amp;gt;case($row.PRIORITY CODE$=="1","Resolution Time&amp;amp;lt;=120",true(),"Resolution Time&amp;amp;gt;2880")&amp;lt;/eval&amp;gt;
    &amp;lt;/drilldown&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should set the token res_time to either &lt;CODE&gt;"Resolution Time&amp;lt;120"&lt;/CODE&gt; or &lt;CODE&gt;"Resolution Time&amp;gt;2880"&lt;/CODE&gt; depending on your &lt;STRONG&gt;PRIORITY CODE&lt;/STRONG&gt; value is 1 or not.&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;Your current query seems to be incorrect anyways. If you want to perform search on the result/s of your main search you can use the map command. Following is a run anywhere search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval testValue=0
| eval searchQuery=case(testValue=="0","INFO",testValue=="1","WARN",testValue=="2","ERROR",1==1,"*")
| table searchQuery
| map search="search index=_internal sourcetype=splunkd log_level=\"$searchQuery$\"| head 1| eval myFilter="\$searchQuery$\"| table _time myFilter _raw"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can also refer to my recent answer on the same line... &lt;A href="https://answers.splunk.com/answers/515546/how-to-create-dynamic-commands-in-search.html#answer-517907"&gt;https://answers.splunk.com/answers/515546/how-to-create-dynamic-commands-in-search.html#answer-517907&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Splunk Documentation on map command for your reference: &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Map"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Map&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 08:47:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309600#M175002</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-04-04T08:47:47Z</dc:date>
    </item>
    <item>
      <title>Re: pass case statement result to search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309601#M175003</link>
      <description>&lt;P&gt;It is there.  But I cannot call straight forward field.  I need to invoke in this way.  Is it possible &lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 08:49:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309601#M175003</guid>
      <dc:creator>k_harini</dc:creator>
      <dc:date>2017-04-04T08:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: pass case statement result to search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309602#M175004</link>
      <description>&lt;P&gt;Thanks.  Will try.  My current query pulls Resolution Time comparison.  But If I pass in search I get no results found&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 08:57:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309602#M175004</guid>
      <dc:creator>k_harini</dc:creator>
      <dc:date>2017-04-04T08:57:21Z</dc:date>
    </item>
    <item>
      <title>Re: pass case statement result to search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309603#M175005</link>
      <description>&lt;P&gt;Your references to the field names with spaces is wrong which is why I try to avoid field names with spaces until the end and then rename them with &lt;CODE&gt;| rename Field_with_spaces AS "Field with spaces"&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;In any case, try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="test" | eval res_time = case( 'PRIORITY CODE' == 1, 'Resolution Time' &amp;lt;= 120, true(), 'Resolution Time' &amp;lt; 2880) | table res_time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="test" | eval res_time = case( $PRIORITY CODE$ == 1, $Resolution Time$ &amp;lt;= 120, true(), $Resolution Time$ &amp;lt; 2880) | table res_time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But that will need adjustment if saved into a dashboard panel.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 20:30:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309603#M175005</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-04-04T20:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: pass case statement result to search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309604#M175006</link>
      <description>&lt;P&gt;What is the search where you want to use the &lt;STRONG&gt;res_time&lt;/STRONG&gt; field?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 20:43:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309604#M175006</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-04-04T20:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: pass case statement result to search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309605#M175007</link>
      <description>&lt;P&gt;If you are wanting to "pass this to the search", then you have to pass values that will actually tell the search what events to search for.  &lt;/P&gt;

&lt;P&gt;In this case, you need to pass "PRIORITY CODE" = "1"  or pass "PRIORITY CODE" != "1".&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2017 21:39:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309605#M175007</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-04-04T21:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: pass case statement result to search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309606#M175008</link>
      <description>&lt;P&gt;Thanks woodcock. I will  try this.  Actually I get result with resolution time&amp;gt;120, resolution time&amp;lt;240..etc. But when I pass to search I have to pass only resolution time in quotes for it to work..  That I could not achieve.  Will try this.  &lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2017 16:48:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309606#M175008</guid>
      <dc:creator>k_harini</dc:creator>
      <dc:date>2017-04-05T16:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: pass case statement result to search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309607#M175009</link>
      <description>&lt;P&gt;I have to search the events and pull only those records that fall into resolution comparison criteria.  That criteria will come from another table cell drill down. It's kind of sla calculation based on this time in each cell..   &lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2017 16:50:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309607#M175009</guid>
      <dc:creator>k_harini</dc:creator>
      <dc:date>2017-04-05T16:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: pass case statement result to search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309608#M175010</link>
      <description>&lt;P&gt;@k_harini... I have updated my answer with one of the approaches to use eval to set token during table drilldown. You can get your search filter query through case statement in eval.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;eval token="res_time"&amp;gt;case($row.PRIORITY CODE$=="1","Resolution Time&amp;amp;lt;=120",true(),"Resolution Time&amp;amp;gt;2880")&amp;lt;/eval&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Apr 2017 04:29:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309608#M175010</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-04-07T04:29:55Z</dc:date>
    </item>
    <item>
      <title>Re: pass case statement result to search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309609#M175011</link>
      <description>&lt;P&gt;@k_harini, please try out and confirm whether you were able to proceed or not.&lt;/P&gt;</description>
      <pubDate>Sat, 08 Apr 2017 10:28:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/pass-case-statement-result-to-search-string/m-p/309609#M175011</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-04-08T10:28:16Z</dc:date>
    </item>
  </channel>
</rss>

