<?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: Display all results if text field is * , or partials results based on any part of phone number entered in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Display-all-results-if-text-field-is-or-partials-results-based/m-p/742198#M240798</link>
    <description>&lt;P&gt;Thanks to &lt;A class="" href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901" target="_self"&gt;&lt;SPAN class=""&gt;yuanliu&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;!&amp;nbsp; the code below worked.&amp;nbsp; &amp;nbsp;Sorry about the typos...that was just some fat-fingering trying to post the query.&amp;nbsp;&amp;nbsp; I was not aware of the the&amp;nbsp;&lt;EM&gt;true()&lt;/EM&gt; function, but learn something new everyday.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;where if ("$PhoneNumber$" ="*", true(), like('Wireless number and descriptions',"%$PhoneNumber$%"))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Mar 2025 13:30:38 GMT</pubDate>
    <dc:creator>JohnD-Splunker</dc:creator>
    <dc:date>2025-03-19T13:30:38Z</dc:date>
    <item>
      <title>Display all results if text field is * , or partials results based on any part of phone number entered</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Display-all-results-if-text-field-is-or-partials-results-based/m-p/742120#M240775</link>
      <description>&lt;P&gt;I'm trying to have the dashboard return all results if the text field is * or return all phone numbers with a partial search in the text box.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;    &amp;lt;input type="text" token="PhoneNumber" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;Phone number to search&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;*&amp;lt;/default&amp;gt;
    &amp;lt;/input&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;The search on the dashboard panel:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="cellulardata"   | where if ($PhoneNumber$ ="*", (like('Wireless number and descriptions',"%"),like('Wireless Number and descriptions',"%$phonenumber$%" ) |  eval Type=if(like(lower('Charge description'), "%text%")  OR like(lower('Charge description'), "%ict%"), "Text", "Voice") | eval Direction=if (Type="Voice" AND 'Called city_state' = "INCOMING,CL","Incoming","Outgoing") | eval datetime =Date." ".Time | eval _time=strptime (datetime,"%m/%d/%Y %H:%M") | eval DateTime=strftime(_time, "%m/%d/%y %I:%M %p") |  eval To_from=replace (To_from,"\.","") | table DateTime, "Wireless number and descriptions", To_from, Type, Direction |rename "Wireless number and descriptions" as Number | sort -DateTime&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The query&amp;nbsp; returns no results no matter if the text field is empty or not.&amp;nbsp; &amp;nbsp; I've removed the entry below from the search,&amp;nbsp; so I know the rest of the search works:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;where if ($PhoneNumber$ ="*", (like('Wireless number and descriptions',"%"),like('Wireless Number and descriptions',"%$phonenumber$%"&lt;/LI-CODE&gt;&lt;P&gt;I've tried comparing this to other dashboards I've seen and searching google,&amp;nbsp; but no luck for some reason.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Mar 2025 16:09:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Display-all-results-if-text-field-is-or-partials-results-based/m-p/742120#M240775</guid>
      <dc:creator>JohnD-Splunker</dc:creator>
      <dc:date>2025-03-18T16:09:45Z</dc:date>
    </item>
    <item>
      <title>Re: Display all results if text field is * , or partials results based on any part of phone number entered</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Display-all-results-if-text-field-is-or-partials-results-based/m-p/742122#M240776</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/308459"&gt;@JohnD-Splunker&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a suspicion that when you do&amp;nbsp;$PhoneNumber$ ="*" your actually going to end up with &lt;EM&gt;*="*"&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I would suggest updating $PhoneNumber$ to&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;$PhoneNumber|s$&lt;/LI-CODE&gt;&lt;P&gt;This adds quotes around the value.&lt;/P&gt;&lt;P&gt;Please let me know how you get on and consider adding karma to this or any other answer if it has helped.&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Will&lt;/P&gt;</description>
      <pubDate>Tue, 18 Mar 2025 16:14:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Display-all-results-if-text-field-is-or-partials-results-based/m-p/742122#M240776</guid>
      <dc:creator>livehybrid</dc:creator>
      <dc:date>2025-03-18T16:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: Display all results if text field is * , or partials results based on any part of phone number entered</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Display-all-results-if-text-field-is-or-partials-results-based/m-p/742139#M240780</link>
      <description>&lt;P&gt;First thing to do in such cases is to click "open in search" and check what the actual search is being rendered into after substituting the tokens.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Mar 2025 17:24:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Display-all-results-if-text-field-is-or-partials-results-based/m-p/742139#M240780</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-03-18T17:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: Display all results if text field is * , or partials results based on any part of phone number entered</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Display-all-results-if-text-field-is-or-partials-results-based/m-p/742162#M240785</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;The query&amp;nbsp; returns no results no matter if the text field is empty or not.&amp;nbsp; &amp;nbsp; I've removed the entry below from the search,&amp;nbsp; so I know the rest of the search works:&lt;/BLOCKQUOTE&gt;&lt;LI-CODE lang="markup"&gt;where if ($PhoneNumber$ ="*", (like('Wireless number and descriptions',"%"),like('Wireless Number and descriptions',"%$phonenumber$%"&lt;/LI-CODE&gt;&lt;HR /&gt;&lt;P&gt;&lt;SPAN&gt;So many problems in your description. &amp;nbsp;First of all, the above search misspells the token name as $phonenumber$ in the second value when your input defines a token named &lt;FONT face="courier new,courier"&gt;PhoneNumber&lt;/FONT&gt; (with camel case). &amp;nbsp;If that's the search in your panel, Splunk will be "waiting for input" no matter what you do.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Secondly, if you correct the token name, the &lt;FONT face="courier new,courier"&gt;if&lt;/FONT&gt; function contains several misplaced parentheses that will give syntax error. &amp;nbsp;If you want to include SPL snippets in question, do not make volunteers guess what you actually meant. &amp;nbsp;It is fair to modify your samples to conceal sensitive info. &amp;nbsp;But make sure the sample is error free.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Correcting for the two obvious errors, your example will look like&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;where if ($PhoneNumber$ ="*", like('Wireless number and descriptions',"%"),like('Wireless Number and descriptions',"%$PhoneNumber$%"))&lt;/LI-CODE&gt;&lt;P&gt;Here is problem 3:&amp;nbsp;&lt;SPAN&gt;if you enter&amp;nbsp;&lt;SPAN&gt;no text, Splunk not only returns nothing, but will also give you an error&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="100%"&gt;&lt;SPAN&gt;Error in 'where' command: The expression is malformed. An unexpected character is reached at '* ="*", like('Wireless number and descriptions',"%"),like('Wireless Number and descriptions',"%*%"))'.&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;In an evaluation context (which &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Where" target="_blank" rel="noopener"&gt;where&lt;/A&gt; command uses), if you want to use a token as literal string, you must quote it.&lt;/P&gt;&lt;P&gt;Correcting for this 3rd error, you get&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;where if ("$PhoneNumber$" ="*", like('Wireless number and descriptions',"%"),like('Wireless Number and descriptions',"%$PhoneNumber$%"))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While this gives you output when you enter nothing into input, it has a 4th problem that you can diagnose using &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;'s suggestion by clicking the magnifying glass: your second value in the &lt;FONT face="courier new,courier"&gt;if&lt;/FONT&gt; function misspells field name&amp;nbsp;&lt;U&gt;&lt;FONT face="courier new,courier"&gt;Wireless number and descriptions&lt;/FONT&gt;&lt;/U&gt; - "number" is spelled with a capital N. &amp;nbsp;I deduce that your field name contains the word "number" with lower case because you said when you enter a valid phone number your mistaken dashboard still returns nothing. (Also because in the rest of the search you used all-lower case "number".&lt;/P&gt;&lt;P&gt;So, the least you can change to is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;where if ("$PhoneNumber$" ="*", like('Wireless number and descriptions',"%"),like('Wireless number and descriptions',"%$PhoneNumber$%"))&lt;/LI-CODE&gt;&lt;P&gt;However, the first value in the expression is a waste because&amp;nbsp;&lt;FONT face="courier new,courier"&gt;like('Wireless number and descriptions',"%")&lt;/FONT&gt; always evaluates to true. &amp;nbsp;You should tell the compiler to just do so.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;where if ("$PhoneNumber$" ="*", true(), like('Wireless number and descriptions',"%$PhoneNumber$%"))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But then, why invoke &lt;FONT face="courier new,courier"&gt;if&lt;/FONT&gt; function if you can just use a search term? &amp;nbsp;How about&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="cellulardata" "Wireless number and descriptions" = "*$phonenumber$*"
| eval Type=if(like(lower('Charge description'), "%text%")  OR like(lower('Charge description'), "%ict%"), "Text", "Voice")
| eval Direction=if (Type="Voice" AND 'Called city_state' = "INCOMING,CL","Incoming","Outgoing")
| eval datetime =Date." ".Time
| eval _time=strptime (datetime,"%m/%d/%Y %H:%M")
| eval DateTime=strftime(_time, "%m/%d/%y %I:%M %p")
| eval To_from=replace (To_from,"\.","")
| table DateTime, "Wireless number and descriptions", To_from, Type, Direction
| rename "Wireless number and descriptions" as Number
| sort -DateTime&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2025 05:44:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Display-all-results-if-text-field-is-or-partials-results-based/m-p/742162#M240785</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2025-03-19T05:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: Display all results if text field is * , or partials results based on any part of phone number entered</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Display-all-results-if-text-field-is-or-partials-results-based/m-p/742198#M240798</link>
      <description>&lt;P&gt;Thanks to &lt;A class="" href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901" target="_self"&gt;&lt;SPAN class=""&gt;yuanliu&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;!&amp;nbsp; the code below worked.&amp;nbsp; &amp;nbsp;Sorry about the typos...that was just some fat-fingering trying to post the query.&amp;nbsp;&amp;nbsp; I was not aware of the the&amp;nbsp;&lt;EM&gt;true()&lt;/EM&gt; function, but learn something new everyday.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;where if ("$PhoneNumber$" ="*", true(), like('Wireless number and descriptions',"%$PhoneNumber$%"))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2025 13:30:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Display-all-results-if-text-field-is-or-partials-results-based/m-p/742198#M240798</guid>
      <dc:creator>JohnD-Splunker</dc:creator>
      <dc:date>2025-03-19T13:30:38Z</dc:date>
    </item>
  </channel>
</rss>

