<?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 function not working with where condition in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Like-function-not-working-with-where-condition/m-p/625342#M217379</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to execute the rest of the statement (in this case table command), only when my parent string contains the substring. The reason I am using variables enclosed in $, is that in real-time, the values are not fixed and will be changed as per the indexed records.&lt;BR /&gt;&lt;BR /&gt;Now if I replace the where command in my query with the following then it works. But again the question is how do I make this like command along with where command to accept a variable instead of a hardcoded value like "%1114%".&lt;BR /&gt;&lt;BR /&gt;| where like (train2, "%1114%")&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Chetan&lt;/P&gt;</description>
    <pubDate>Tue, 27 Dec 2022 16:29:22 GMT</pubDate>
    <dc:creator>chetanN</dc:creator>
    <dc:date>2022-12-27T16:29:22Z</dc:date>
    <item>
      <title>Like function not working with where condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Like-function-not-working-with-where-condition/m-p/625293#M217362</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I am trying to run a basic search where I am trying to print table based on where and like() condition. But its not working. Following is a query. It is always showing 0 results.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index="traindetails" sourcetype=*
| eval trainNumber="1114"
| eval train2 = A_BCD_1114_EFG
| where like(train2,"%$trainNumber$%")
| table trainNumber,train2

I also tried following but no luck.

| where like(train2,"%"+$trainNumber$+"%")&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;can someone please help?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 29 Dec 2022 04:11:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Like-function-not-working-with-where-condition/m-p/625293#M217362</guid>
      <dc:creator>chetanN</dc:creator>
      <dc:date>2022-12-29T04:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: Like function not working with where condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Like-function-not-working-with-where-condition/m-p/625298#M217364</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/252447"&gt;@chetanN&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Like is a function usable only in eval command, not in where:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="traindetails" sourcetype=*
| eval trainNumber="1114"
| eval train2 = A_BCD_1114_EFG
| search train2="*$trainNumber$*"
| table trainNumber,train2&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 07:45:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Like-function-not-working-with-where-condition/m-p/625298#M217364</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-12-27T07:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: Like function not working with where condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Like-function-not-working-with-where-condition/m-p/625311#M217372</link>
      <description>&lt;P&gt;The official docs seem to disagree with you on this &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/SCS/current/SearchReference/ConditionalFunctions#like.28.26lt.3Bstr.26gt.3B.2C_.26lt.3Bpattern.26gt.3B.29" target="_blank"&gt;https://docs.splunk.com/Documentation/SCS/current/SearchReference/ConditionalFunctions#like.28.26lt.3Bstr.26gt.3B.2C_.26lt.3Bpattern.26gt.3B.29&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/252447"&gt;@chetanN&lt;/a&gt;I'm not sure what the logic of your search should be. If you expect the $trainNumber$ string to work as a token name to be replaced with the trainNumber field value - it won't work that way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 09:09:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Like-function-not-working-with-where-condition/m-p/625311#M217372</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-12-27T09:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: Like function not working with where condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Like-function-not-working-with-where-condition/m-p/625342#M217379</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to execute the rest of the statement (in this case table command), only when my parent string contains the substring. The reason I am using variables enclosed in $, is that in real-time, the values are not fixed and will be changed as per the indexed records.&lt;BR /&gt;&lt;BR /&gt;Now if I replace the where command in my query with the following then it works. But again the question is how do I make this like command along with where command to accept a variable instead of a hardcoded value like "%1114%".&lt;BR /&gt;&lt;BR /&gt;| where like (train2, "%1114%")&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Chetan&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 16:29:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Like-function-not-working-with-where-condition/m-p/625342#M217379</guid>
      <dc:creator>chetanN</dc:creator>
      <dc:date>2022-12-27T16:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: Like function not working with where condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Like-function-not-working-with-where-condition/m-p/625343#M217380</link>
      <description>&lt;P&gt;Thanks for taking the time. But it did not work for me.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 16:25:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Like-function-not-working-with-where-condition/m-p/625343#M217380</guid>
      <dc:creator>chetanN</dc:creator>
      <dc:date>2022-12-27T16:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: Like function not working with where condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Like-function-not-working-with-where-condition/m-p/625348#M217383</link>
      <description>&lt;P&gt;OK. I understand that you're trying to filter the results in your pipeline before passing them down to further commands. But I don't quite get why you firstly set the field to some constant value (for all events at that time, mind you!) and then try to use that field's value (not a variable, there is no such concept in Splunk generally speaking).&lt;/P&gt;&lt;P&gt;Try to describe your problem. Not what you're trying to &lt;U&gt;do,&lt;/U&gt; but what you whant to &lt;U&gt;achieve&lt;/U&gt;. I mean what is the relation between input and output.&lt;/P&gt;&lt;P&gt;You probably could render the value of your field to a string and use it in the "where" comparison but the question is what is this value, where does it come from and how it ended here.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 17:58:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Like-function-not-working-with-where-condition/m-p/625348#M217383</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-12-27T17:58:05Z</dc:date>
    </item>
  </channel>
</rss>

