<?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: Filter based on token from macro in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Filter-based-on-token-from-macro/m-p/673208#M230534</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/263242"&gt;@dtburrows3&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Thanks for your response!&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;If we need to add those two lined in a single search of macro, where we are receiving Type as a token from Search/dashboard, How to do that?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;I tried this&amp;nbsp; way, It dosen't work&lt;BR /&gt;&lt;BR /&gt;| where if(macth('Type', "ADZ"), "match(Assetname, \"^\\S{2}Z\")", "isnotnull(Assetname)")&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks in Advance!&lt;/P&gt;</description>
    <pubDate>Thu, 04 Jan 2024 12:18:14 GMT</pubDate>
    <dc:creator>smanojkumar</dc:creator>
    <dc:date>2024-01-04T12:18:14Z</dc:date>
    <item>
      <title>Filter based on token from macro</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Filter-based-on-token-from-macro/m-p/673121#M230507</link>
      <description>&lt;P&gt;Hi Splunkers!&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; I would like to filter in a field when I received a specific value from multiselect input dropdown,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I'm having a field "Type" where I will get multiselect values, that will be passed to a search by macro, in that search, i would like to filter "Assetname" with field of having Z in 3rd letter, only when I'm getting ADZ value from the field "Type"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I'm not getting the value ADZ, i need to get all values in the field Assetname&lt;BR /&gt;&lt;BR /&gt;Type - Indus, ADZ, Stan&lt;BR /&gt;Assetname - abZahd-2839&lt;/P&gt;&lt;P&gt;so, the Assetname with 3rd letter Z needs to be filtered.&lt;BR /&gt;&lt;BR /&gt;Thanks in Advance!&lt;/P&gt;&lt;P&gt;Manoj Kumar S&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2024 11:04:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Filter-based-on-token-from-macro/m-p/673121#M230507</guid>
      <dc:creator>smanojkumar</dc:creator>
      <dc:date>2024-01-03T11:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: Filter based on token from macro</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Filter-based-on-token-from-macro/m-p/673141#M230510</link>
      <description>&lt;P&gt;I think you could put in a change tag in the multiselect to evaluate a new token to use as a conditional filter based on the selection of the multiselect.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;input type="multiselect" token="Type" searchWhenChanged="true"&amp;gt;
  &amp;lt;choice value="ADZ"&amp;gt;ADZ&amp;lt;/choice&amp;gt;
  ...
  &amp;lt;change&amp;gt;
    &amp;lt;eval token="assetname_filter"&amp;gt;if(match('Type', "ADZ"), "match(Assetname, \"^\\S{2}Z\")", "isnotnull(Assetname)")&amp;lt;/eval&amp;gt;
  &amp;lt;/change&amp;gt;
  ...
&amp;lt;/input&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And then in the search you are wanting to filter you can use the $assetname_filter$ token after a where command&amp;nbsp; like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;base_search&amp;gt;
    | where $assetname_filter$&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Examples of functionality:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; No ADZ selected (All assets showing)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_0-1704297150411.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28738i7A93B7C44D12A995/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_0-1704297150411.png" alt="dtburrows3_0-1704297150411.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; ADZ one of the values selected in the multiselect (Only **Z* Assetname are in final output)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_1-1704297224464.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28739iF51716FF4ACEC80F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_1-1704297224464.png" alt="dtburrows3_1-1704297224464.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2024 15:54:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Filter-based-on-token-from-macro/m-p/673141#M230510</guid>
      <dc:creator>dtburrows3</dc:creator>
      <dc:date>2024-01-03T15:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: Filter based on token from macro</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Filter-based-on-token-from-macro/m-p/673208#M230534</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/263242"&gt;@dtburrows3&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Thanks for your response!&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;If we need to add those two lined in a single search of macro, where we are receiving Type as a token from Search/dashboard, How to do that?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;I tried this&amp;nbsp; way, It dosen't work&lt;BR /&gt;&lt;BR /&gt;| where if(macth('Type', "ADZ"), "match(Assetname, \"^\\S{2}Z\")", "isnotnull(Assetname)")&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks in Advance!&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 12:18:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Filter-based-on-token-from-macro/m-p/673208#M230534</guid>
      <dc:creator>smanojkumar</dc:creator>
      <dc:date>2024-01-04T12:18:14Z</dc:date>
    </item>
    <item>
      <title>Re: Filter based on token from macro</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Filter-based-on-token-from-macro/m-p/673250#M230540</link>
      <description>&lt;P&gt;the where command is expecting some sort of boolean result after the logic statement is evaluated. The if() function you shared is passing just another logic statement. I think to do it in a where command would look something like this.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where if(((match('Type', "ADZ") AND match('Assetname', "^\S{2}Z")) OR NOT match('Type', "ADZ")), True(), False())&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Note: This method is expecting the field Type and Assetname to both be available fields in the dataset up to the point of it's execution. So a simple example of making the "Type" field available from the multiselect would be&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;base_search&amp;gt;
    ``` make the multiselect token value an available field in the dataset ```
    ``` Since it is common for multiselect token values to be formatted with double-quotes, doing a $&amp;lt;token_name&amp;gt;|s$ here should account for that ```
    ``` It is assumed that the field "Assetname" is available and derived from &amp;lt;base_search&amp;gt; above. ```
    | eval
        Type=$Type|s$
    | where if(((match('Type', "ADZ") AND match('Assetname', "^\S{2}Z")) OR NOT match('Type', "ADZ")), True(), False())&lt;/LI-CODE&gt;&lt;P&gt;Examples: (with ADZ in Type token)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_0-1704387278104.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28760i32C9252CCC25CA66/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_0-1704387278104.png" alt="dtburrows3_0-1704387278104.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;(without ADZ in Type token)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_1-1704387316763.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28761iD1C8D95EB9C13354/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_1-1704387316763.png" alt="dtburrows3_1-1704387316763.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 16:55:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Filter-based-on-token-from-macro/m-p/673250#M230540</guid>
      <dc:creator>dtburrows3</dc:creator>
      <dc:date>2024-01-04T16:55:25Z</dc:date>
    </item>
  </channel>
</rss>

