<?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: Return fields based on boolean value in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Return-fields-based-on-boolean-value/m-p/312047#M160145</link>
    <description>&lt;P&gt;Thanks @niketnilay! I'd wish you'd submitted this as an answer, so I could accept it. The boolean field is input from a checkbox in a dashboard which will be used in a search.&lt;/P&gt;</description>
    <pubDate>Fri, 21 Jul 2017 07:21:03 GMT</pubDate>
    <dc:creator>hegga</dc:creator>
    <dc:date>2017-07-21T07:21:03Z</dc:date>
    <item>
      <title>Return fields based on boolean value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-fields-based-on-boolean-value/m-p/312045#M160143</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a saved search used by a dashboard which should return different fields based on the boolean value of a string. For example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;if $show_raw_log$ == 1 do
   | fields _raw

if $show_raw_log$ == 0 do
   | fields _time,  sender, recipient, message_subject, attachment, vendor_action, message_id
   | fields - _raw
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How can I achieve this in Splunk?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 08:21:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-fields-based-on-boolean-value/m-p/312045#M160143</guid>
      <dc:creator>hegga</dc:creator>
      <dc:date>2017-07-13T08:21:25Z</dc:date>
    </item>
    <item>
      <title>Re: Return fields based on boolean value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-fields-based-on-boolean-value/m-p/312046#M160144</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/200547"&gt;@hegga&lt;/a&gt;, more details please. What sets the Boolean value &lt;CODE&gt;$show_raw_log$&lt;/CODE&gt;, is it going to be a form input, a search or a drilldown event?&lt;/P&gt;

&lt;P&gt;In any case you can use eval tag to set a query string token to be passed to your actual search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;eval token="queryString"&amp;gt;if($show_raw_log$==1, "| fields _raw", "| fields _time,  sender, recipient, message_subject, attachment, vendor_action, message_id | fields - _raw")&amp;lt;/eval&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then use token &lt;CODE&gt;queryString&lt;/CODE&gt; in your actual search.&lt;BR /&gt;
PS: Where ever in your current code you are setting $show_raw_log$ eval tag similar to the one above needs to be added, which implies $show_raw_log$ might not exist or may be represented by some other field/value or token.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:59:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-fields-based-on-boolean-value/m-p/312046#M160144</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2020-09-29T14:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: Return fields based on boolean value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-fields-based-on-boolean-value/m-p/312047#M160145</link>
      <description>&lt;P&gt;Thanks @niketnilay! I'd wish you'd submitted this as an answer, so I could accept it. The boolean field is input from a checkbox in a dashboard which will be used in a search.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 07:21:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-fields-based-on-boolean-value/m-p/312047#M160145</guid>
      <dc:creator>hegga</dc:creator>
      <dc:date>2017-07-21T07:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: Return fields based on boolean value</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Return-fields-based-on-boolean-value/m-p/312048#M160146</link>
      <description>&lt;P&gt;@hegga, I have converted to answer. Please accept &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 07:24:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Return-fields-based-on-boolean-value/m-p/312048#M160146</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-07-21T07:24:43Z</dc:date>
    </item>
  </channel>
</rss>

