<?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: LIKE() with wildcard within an IF statement in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/LIKE-with-wildcard-within-an-IF-statement/m-p/29542#M1221</link>
    <description>&lt;P&gt;I have tried both " and ". Both produce an error.&lt;/P&gt;</description>
    <pubDate>Sat, 14 Aug 2010 03:43:29 GMT</pubDate>
    <dc:creator>Tisiphone_1</dc:creator>
    <dc:date>2010-08-14T03:43:29Z</dc:date>
    <item>
      <title>LIKE() with wildcard within an IF statement</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/LIKE-with-wildcard-within-an-IF-statement/m-p/29538#M1217</link>
      <description>&lt;P&gt;Can anybody tell me why this LIKE statement using a wildcard errors out within an IF statement in a form search, but not in the standard search box?&lt;/P&gt;

&lt;P&gt;Here's the whole form search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   &amp;lt;searchTemplate&amp;gt;
   index=test
   [stats count | eval search=(

           if("$VAR$"=="empty"," "," | where like(field,%$VAR$%) ")

   ) 

   | fields - count ]
   &amp;lt;/searchTemplate&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The part that never works is the LIKE statement % (the search wildcard):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where like(field,%$VAR$%)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have tried using ASCII instead of symbol %, and quotes in different places. The error I receive is: &lt;EM&gt;"Error in 'eval' command: Typechecking failed. '%' only takes numbers."&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;However, in standard search,:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where like(field,%stuff%) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;works just fine.&lt;/P&gt;

&lt;P&gt;FYI: I am using 4.0.11 - it appears LIKE may function differently than newer versions.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Aug 2010 06:09:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/LIKE-with-wildcard-within-an-IF-statement/m-p/29538#M1217</guid>
      <dc:creator>Tisiphone_1</dc:creator>
      <dc:date>2010-08-13T06:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: LIKE() with wildcard within an IF statement</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/LIKE-with-wildcard-within-an-IF-statement/m-p/29539#M1218</link>
      <description>&lt;P&gt;Can you clarify what the output of the search should be?  It appears that you're trying to generate SQL-like search syntax within the search language -- there probably is a simpler way to achieve what you want.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Aug 2010 12:37:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/LIKE-with-wildcard-within-an-IF-statement/m-p/29539#M1218</guid>
      <dc:creator>Johnvey</dc:creator>
      <dc:date>2010-08-13T12:37:16Z</dc:date>
    </item>
    <item>
      <title>Re: LIKE() with wildcard within an IF statement</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/LIKE-with-wildcard-within-an-IF-statement/m-p/29540#M1219</link>
      <description>&lt;P&gt;Eval and where require that the pattern for a LIKE expression be a string literal. Your syntax should be &lt;CODE&gt;| where like(field,"%stuff%")&lt;/CODE&gt;. I think that it's working in some of the cases because the UI is injecting quotes (where they don't necessarily belong).&lt;/P&gt;</description>
      <pubDate>Fri, 13 Aug 2010 22:34:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/LIKE-with-wildcard-within-an-IF-statement/m-p/29540#M1219</guid>
      <dc:creator>Stephen_Sorkin</dc:creator>
      <dc:date>2010-08-13T22:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: LIKE() with wildcard within an IF statement</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/LIKE-with-wildcard-within-an-IF-statement/m-p/29541#M1220</link>
      <description>&lt;P&gt;I'm letting a user put a string into a search box, and if the search box is not empty I am searching for things that contain that string.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Aug 2010 03:42:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/LIKE-with-wildcard-within-an-IF-statement/m-p/29541#M1220</guid>
      <dc:creator>Tisiphone_1</dc:creator>
      <dc:date>2010-08-14T03:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: LIKE() with wildcard within an IF statement</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/LIKE-with-wildcard-within-an-IF-statement/m-p/29542#M1221</link>
      <description>&lt;P&gt;I have tried both " and ". Both produce an error.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Aug 2010 03:43:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/LIKE-with-wildcard-within-an-IF-statement/m-p/29542#M1221</guid>
      <dc:creator>Tisiphone_1</dc:creator>
      <dc:date>2010-08-14T03:43:29Z</dc:date>
    </item>
    <item>
      <title>Re: LIKE() with wildcard within an IF statement</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/LIKE-with-wildcard-within-an-IF-statement/m-p/29543#M1222</link>
      <description>&lt;P&gt;If you paste this search into the Summary view of search, does it seem to land in the flash timeline intact?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Aug 2010 15:45:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/LIKE-with-wildcard-within-an-IF-statement/m-p/29543#M1222</guid>
      <dc:creator>jrodman</dc:creator>
      <dc:date>2010-08-19T15:45:26Z</dc:date>
    </item>
    <item>
      <title>Re: LIKE() with wildcard within an IF statement</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/LIKE-with-wildcard-within-an-IF-statement/m-p/29544#M1223</link>
      <description>&lt;P&gt;oiResult=failure | where like(oiErrorString, "%5 - invalid truck number DSN%")&lt;/P&gt;

&lt;P&gt;Works for me with version 6.0&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jan 2014 14:13:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/LIKE-with-wildcard-within-an-IF-statement/m-p/29544#M1223</guid>
      <dc:creator>jetie</dc:creator>
      <dc:date>2014-01-03T14:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: LIKE() with wildcard within an IF statement</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/LIKE-with-wildcard-within-an-IF-statement/m-p/29545#M1224</link>
      <description>&lt;P&gt;I know its too late to reply but not too late to contribute. &lt;BR /&gt;
I am working on same kind of thing here my query which worked for me .&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;|where like(label,"%"+"$Token_Name$"+"%") OR like(label,"%"+"$Token_Name_part$"+"%")&lt;/CODE&gt; &lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2016 03:47:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/LIKE-with-wildcard-within-an-IF-statement/m-p/29545#M1224</guid>
      <dc:creator>kartik13</dc:creator>
      <dc:date>2016-06-24T03:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: LIKE() with wildcard within an IF statement</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/LIKE-with-wildcard-within-an-IF-statement/m-p/29546#M1225</link>
      <description>&lt;P&gt;The above syntax of including "%" in a separate set of quotes from the token, did not work for me. After a lot of trial and error, what worked was this, ie., encapsulating the "%" within the SAME SET of quotes as the token:&lt;/P&gt;

&lt;P&gt;| where like(label,"%$Token_Name$%")&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jul 2019 17:01:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/LIKE-with-wildcard-within-an-IF-statement/m-p/29546#M1225</guid>
      <dc:creator>rey123</dc:creator>
      <dc:date>2019-07-03T17:01:03Z</dc:date>
    </item>
  </channel>
</rss>

