<?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: Using eval within a Search Template? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-eval-within-a-Search-Template/m-p/19238#M679</link>
    <description>&lt;P&gt;You would need:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=test  [ stats count | eval search=if($String1$ == "NOTSPECIFIED"," ","Search1=$String1$") | fields - count ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can't expand a variable name in the search command. Using a subsearch is a way around that. You also will have much better performance. The other way would have to retrieve the entire index first, then filter it.&lt;/P&gt;</description>
    <pubDate>Fri, 23 Jul 2010 07:36:08 GMT</pubDate>
    <dc:creator>gkanapathy</dc:creator>
    <dc:date>2010-07-23T07:36:08Z</dc:date>
    <item>
      <title>Using eval within a Search Template?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-eval-within-a-Search-Template/m-p/19237#M678</link>
      <description>&lt;P&gt;Apologies if this is a novice question, but when I attempt to use any eval statement within a form Search Template, nothing appears to work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    &amp;lt;searchTemplate&amp;gt;

    index=test | eval searchstring = if($String1$ == "NOTSPECIFIED"," ","Search1=$String1$") 
  | search index=test $searchstring$

    &amp;lt;/searchTemplate&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there something obvious that I am doing wrong? I am looking at the eval documentation, and this seems to be precisely how you are supposed to set a value to a variable. Yet, the variable does not seem usable in the next search. When I look at my search results, I see the form variables resolving, but not the one I set in the eval statement.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jul 2010 06:56:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Using-eval-within-a-Search-Template/m-p/19237#M678</guid>
      <dc:creator>Tisiphone_1</dc:creator>
      <dc:date>2010-07-23T06:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: Using eval within a Search Template?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-eval-within-a-Search-Template/m-p/19238#M679</link>
      <description>&lt;P&gt;You would need:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=test  [ stats count | eval search=if($String1$ == "NOTSPECIFIED"," ","Search1=$String1$") | fields - count ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can't expand a variable name in the search command. Using a subsearch is a way around that. You also will have much better performance. The other way would have to retrieve the entire index first, then filter it.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jul 2010 07:36:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Using-eval-within-a-Search-Template/m-p/19238#M679</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-07-23T07:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using eval within a Search Template?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-eval-within-a-Search-Template/m-p/19239#M680</link>
      <description>&lt;P&gt;Hmm,&lt;/P&gt;

&lt;P&gt;I am doing index=test  [ stats count | eval search=if($String1$ == "NOTSPECIFIED"," ","Search1=$String1$") | fields - count ] | search index=test $search$&lt;/P&gt;

&lt;P&gt;But I always get "The specified search will not match any events"&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jul 2010 08:24:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Using-eval-within-a-Search-Template/m-p/19239#M680</guid>
      <dc:creator>Tisiphone_1</dc:creator>
      <dc:date>2010-07-23T08:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using eval within a Search Template?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-eval-within-a-Search-Template/m-p/19240#M681</link>
      <description>&lt;P&gt;You should not have the additional search at the end.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jul 2010 08:57:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Using-eval-within-a-Search-Template/m-p/19240#M681</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-07-23T08:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: Using eval within a Search Template?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-eval-within-a-Search-Template/m-p/19241#M682</link>
      <description>&lt;P&gt;OK, so 'search' is actually evaluated and piped back.&lt;/P&gt;

&lt;P&gt;What if I want to use more than one IF statement?&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jul 2010 09:10:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Using-eval-within-a-Search-Template/m-p/19241#M682</guid>
      <dc:creator>Tisiphone_1</dc:creator>
      <dc:date>2010-07-23T09:10:38Z</dc:date>
    </item>
    <item>
      <title>Re: Using eval within a Search Template?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-eval-within-a-Search-Template/m-p/19242#M683</link>
      <description>&lt;P&gt;Yes. The subsearch is implicitly sent to "format" and the resulting string inserted into the search. You can either just concatenate a bigger expression into the value "search". Or you can go back and re-do the whole thing as a macro.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Jul 2010 14:09:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Using-eval-within-a-Search-Template/m-p/19242#M683</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-07-23T14:09:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using eval within a Search Template?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-eval-within-a-Search-Template/m-p/19243#M684</link>
      <description>&lt;P&gt;Thanks a bunch. That was much more detail than the documentation goes into.&lt;/P&gt;</description>
      <pubDate>Sat, 24 Jul 2010 03:26:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Using-eval-within-a-Search-Template/m-p/19243#M684</guid>
      <dc:creator>Tisiphone_1</dc:creator>
      <dc:date>2010-07-24T03:26:16Z</dc:date>
    </item>
    <item>
      <title>Re: Using eval within a Search Template?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-eval-within-a-Search-Template/m-p/19244#M685</link>
      <description>&lt;P&gt;Just FYI, it works great, except for one instance - " " OR (argument) is treated as (any) OR (argument).&lt;/P&gt;

&lt;P&gt;I'll find a workaround.&lt;/P&gt;</description>
      <pubDate>Sat, 24 Jul 2010 06:22:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Using-eval-within-a-Search-Template/m-p/19244#M685</guid>
      <dc:creator>Tisiphone_1</dc:creator>
      <dc:date>2010-07-24T06:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: Using eval within a Search Template?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Using-eval-within-a-Search-Template/m-p/19245#M686</link>
      <description>&lt;P&gt;Oh I guess you can also use a second subsearch, not sure if that will help.&lt;/P&gt;</description>
      <pubDate>Sun, 25 Jul 2010 00:58:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Using-eval-within-a-Search-Template/m-p/19245#M686</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2010-07-25T00:58:31Z</dc:date>
    </item>
  </channel>
</rss>

