<?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 exclude condition from search depending on variable? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-condition-from-search-depending-on-variable/m-p/368506#M108608</link>
    <description>&lt;P&gt;You can create the where filter directly from &lt;STRONG&gt;change&lt;/STRONG&gt; event of the dropdown using &lt;STRONG&gt;eval&lt;/STRONG&gt;. I have given an example based on the details provided. Dropdown choice values might change as per your use case (I expected one of the choice values is notdef).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="dropdown" token="dropdown_token" searchWhenChanged="true"&amp;gt;
  &amp;lt;label&amp;gt;Select Field&amp;lt;/label&amp;gt;
  &amp;lt;choice value="notdef"&amp;gt;Not Defined&amp;lt;/choice&amp;gt;
  &amp;lt;choice value="*"&amp;gt;All&amp;lt;/choice&amp;gt;
  &amp;lt;change&amp;gt;
    &amp;lt;eval token="filterQuery"&amp;gt;if($value$=="notdef"," | WHERE param1=$param1_token$ AND param2=$param2_token$", " | WHERE param1=$param1_token$ AND param2=$param2_token$ AND dropdown_param = $value$")&amp;lt;/eval&amp;gt;
  &amp;lt;/change&amp;gt;
&amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 22 Jun 2017 09:48:08 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-06-22T09:48:08Z</dc:date>
    <item>
      <title>How to exclude condition from search depending on variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-condition-from-search-depending-on-variable/m-p/368504#M108606</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;

&lt;P&gt;On my dashboard there is the dropdown list. I want to exlude its token criteria from search query if default value "notdef" is selected. i.e.:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if("$dropdown_token$" == "notdef")
    | WHERE param1 = $param1_token$ AND param2 = $param2_token$
else
    | WHERE param1 = $param1_token$ AND param2 = $param2_token$ AND dropdown_param = $dropdown_token$
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried to use match replaceing "notdef" by empty sting while "notdef" is selected:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval dropdown_req = if("$dropdown_token$" == "notdef", "", "$dropdown_token$")
| WHERE param1 = $param1_token$ AND param2 = $param2_token$ AND match(dropdown_param, dropdown_req)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;, but values of $dropdown_token$ include the sign "*" (e.g. "*A") and it doesn't work in regex in match().&lt;/P&gt;

&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:38:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-condition-from-search-depending-on-variable/m-p/368504#M108606</guid>
      <dc:creator>yurykiselev</dc:creator>
      <dc:date>2020-09-29T14:38:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to exclude condition from search depending on variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-condition-from-search-depending-on-variable/m-p/368505#M108607</link>
      <description>&lt;P&gt;Can you try this way -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval flag=if(like("$dropdown_token$","notdef"),"*","$dropdown_token$") | search param1=$param1_token$ AND param2=$param2_token$ | where dropdown_param=flag
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Jun 2017 07:07:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-condition-from-search-depending-on-variable/m-p/368505#M108607</guid>
      <dc:creator>dineshraj9</dc:creator>
      <dc:date>2017-06-22T07:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to exclude condition from search depending on variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-condition-from-search-depending-on-variable/m-p/368506#M108608</link>
      <description>&lt;P&gt;You can create the where filter directly from &lt;STRONG&gt;change&lt;/STRONG&gt; event of the dropdown using &lt;STRONG&gt;eval&lt;/STRONG&gt;. I have given an example based on the details provided. Dropdown choice values might change as per your use case (I expected one of the choice values is notdef).&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input type="dropdown" token="dropdown_token" searchWhenChanged="true"&amp;gt;
  &amp;lt;label&amp;gt;Select Field&amp;lt;/label&amp;gt;
  &amp;lt;choice value="notdef"&amp;gt;Not Defined&amp;lt;/choice&amp;gt;
  &amp;lt;choice value="*"&amp;gt;All&amp;lt;/choice&amp;gt;
  &amp;lt;change&amp;gt;
    &amp;lt;eval token="filterQuery"&amp;gt;if($value$=="notdef"," | WHERE param1=$param1_token$ AND param2=$param2_token$", " | WHERE param1=$param1_token$ AND param2=$param2_token$ AND dropdown_param = $value$")&amp;lt;/eval&amp;gt;
  &amp;lt;/change&amp;gt;
&amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Jun 2017 09:48:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-condition-from-search-depending-on-variable/m-p/368506#M108608</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-06-22T09:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to exclude condition from search depending on variable?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-condition-from-search-depending-on-variable/m-p/368507#M108609</link>
      <description>&lt;P&gt;I solved this using token prefix-postfix:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;prefix&amp;gt;| where dropdown_param = "&amp;lt;/prefix&amp;gt;
  &amp;lt;suffix&amp;gt;"&amp;lt;/suffix&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and blank as default value.&lt;/P&gt;

&lt;P&gt;Thank you all!&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2017 12:30:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-condition-from-search-depending-on-variable/m-p/368507#M108609</guid>
      <dc:creator>yurykiselev</dc:creator>
      <dc:date>2017-06-22T12:30:15Z</dc:date>
    </item>
  </channel>
</rss>

