<?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: Where clause has syntax error? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Where-clause-has-syntax-error/m-p/582117#M47699</link>
    <description>&lt;P&gt;acharlieh，&lt;/P&gt;&lt;P&gt;sorry for misleading&amp;nbsp; your,&lt;/P&gt;&lt;P&gt;ALL/*&amp;nbsp; here means&amp;nbsp; &amp;nbsp;label/value,&amp;nbsp; &amp;nbsp; when ALL is selected,&amp;nbsp; value is *.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;same thing,&amp;nbsp;VQ_abc_efg is also the value of token.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kevin&lt;/P&gt;</description>
    <pubDate>Sat, 22 Jan 2022 05:04:35 GMT</pubDate>
    <dc:creator>wangkevin1029</dc:creator>
    <dc:date>2022-01-22T05:04:35Z</dc:date>
    <item>
      <title>Where clause has syntax error?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Where-clause-has-syntax-error/m-p/582111#M47697</link>
      <description>&lt;P&gt;Hi, Splunkers,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;| where ENT_CallType=if($t_VQ$ =="*","*",ltrim($t_VQ$,"VQ_"))&lt;/P&gt;&lt;P&gt;t_VQ is a dropdown token,&amp;nbsp; value is either ALL/*&amp;nbsp; or VQ_abc_efg&amp;nbsp; (string starting with VQ_)&lt;/P&gt;&lt;P&gt;what my code expected is&lt;/P&gt;&lt;P&gt;when t_VQ = *,&amp;nbsp; then&amp;nbsp; |where ENT_CallType=*&amp;nbsp;&lt;/P&gt;&lt;P&gt;when t_VQ =&amp;nbsp;VQ_abc_efg,&amp;nbsp; &amp;nbsp;then |where ENT_CallType=abc_efg&lt;/P&gt;&lt;P&gt;but when I selected ALL/*， has the following error&lt;/P&gt;&lt;P&gt;Error in ‘where’ command: The expression is malformed. An unexpected character is reached at ‘* == “*”,”*”, ltrim(*,”VQ_”)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when&amp;nbsp;VQ_abc_efg is selected, doesn't work either.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thx in advance&lt;/P&gt;&lt;P&gt;Kevin&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jan 2022 03:07:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Where-clause-has-syntax-error/m-p/582111#M47697</guid>
      <dc:creator>wangkevin1029</dc:creator>
      <dc:date>2022-01-22T03:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Where clause has syntax error?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Where-clause-has-syntax-error/m-p/582116#M47698</link>
      <description>&lt;P&gt;When you use tokens in dashboards they don't behave like variables, they behave more like #define macros in C... the literal value gets dropped into place where used prior to evaluation. (Ok this is an oversimplification, but when they're in your search strings... )&lt;BR /&gt;&lt;BR /&gt;In the case that when your token has the value ALL/* then your where clause reads:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where ENT_CallType=if(ALL/* =="*","*",ltrim(ALL/*,"VQ_"))&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;To parse that statement in words where the field ENT_CallType has a value equal to ... if ( value of the field ALL divided by multiplied by ... And we've stopped making sense, thus we call it a syntax error when we reach the * coming from your token value.&lt;BR /&gt;&lt;BR /&gt;With the value VQ_abc_efg you don't wind up with the same syntax problem, but you do wind up with something that is obviously not what you were intending:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where ENT_CallType=if(VQ_abc_efg =="*","*",ltrim(VQ_abc_efg ,"VQ_"))&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;Again turning this into words, I'm looking in my results for a field called ENT_CallType, and seeing if it's equal to * when the field named VQ_abc_efg has the value *, otherwise the value of the field VQ_abc_efg removing VQ_ from the front of it...&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I suspect you want to read up on &lt;A href="https://docs.splunk.com/Documentation/Splunk/8.2.4/Viz/tokens#Syntax_to_consume_tokens" target="_blank" rel="noopener"&gt;Syntax to consume tokens&lt;/A&gt;&amp;nbsp;, in particular $tokenname|s$ where your token value gets wrapped in double quotes before it gets inserted (and also helps with escaping quotations within the token value too). There are a few other hints around tokens there too.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jan 2022 04:49:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Where-clause-has-syntax-error/m-p/582116#M47698</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2022-01-22T04:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Where clause has syntax error?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Where-clause-has-syntax-error/m-p/582117#M47699</link>
      <description>&lt;P&gt;acharlieh，&lt;/P&gt;&lt;P&gt;sorry for misleading&amp;nbsp; your,&lt;/P&gt;&lt;P&gt;ALL/*&amp;nbsp; here means&amp;nbsp; &amp;nbsp;label/value,&amp;nbsp; &amp;nbsp; when ALL is selected,&amp;nbsp; value is *.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;same thing,&amp;nbsp;VQ_abc_efg is also the value of token.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kevin&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jan 2022 05:04:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Where-clause-has-syntax-error/m-p/582117#M47699</guid>
      <dc:creator>wangkevin1029</dc:creator>
      <dc:date>2022-01-22T05:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: Where clause has syntax error?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Where-clause-has-syntax-error/m-p/582118#M47700</link>
      <description>&lt;P&gt;No worries, but that distinction doesn't materially change the answer &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where ENT_CallType=if(* =="*","*",ltrim(*,"VQ_"))&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;is just as syntactically wrong as what I thought your token value was&amp;nbsp; ... Do the same exercise and you get ... " if (multiplication operator) is equal to ... " which doesn't make sense.&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jan 2022 05:11:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Where-clause-has-syntax-error/m-p/582118#M47700</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2022-01-22T05:11:15Z</dc:date>
    </item>
    <item>
      <title>Re: Where clause has syntax error?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Where-clause-has-syntax-error/m-p/582119#M47701</link>
      <description>&lt;P&gt;it looks I should use&amp;nbsp; $t_VQ|s$,&amp;nbsp; instead of $t_VQ$, will do more testing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kevin&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jan 2022 05:15:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Where-clause-has-syntax-error/m-p/582119#M47701</guid>
      <dc:creator>wangkevin1029</dc:creator>
      <dc:date>2022-01-22T05:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: Where clause has syntax error?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Where-clause-has-syntax-error/m-p/582121#M47702</link>
      <description>&lt;P&gt;it works when I selected&amp;nbsp; VQ_abc_efg,&amp;nbsp; but when&amp;nbsp; ALL/* is selected, still not working.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Kevin&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jan 2022 05:33:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Where-clause-has-syntax-error/m-p/582121#M47702</guid>
      <dc:creator>wangkevin1029</dc:creator>
      <dc:date>2022-01-22T05:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: Where clause has syntax error?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Where-clause-has-syntax-error/m-p/582122#M47703</link>
      <description>&lt;P&gt;thx,&amp;nbsp; the documentation&amp;nbsp; link you sent reminded me of&amp;nbsp; $t_VB|s$,&amp;nbsp;&lt;/P&gt;&lt;P&gt;now, I run into a similar issue.&lt;/P&gt;&lt;P&gt;how to concatenate a field with a token.&lt;/P&gt;&lt;P&gt;like the following where clause,&amp;nbsp; &amp;nbsp;ENT_CallType is a field,&amp;nbsp; t_CallType is token,&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using . (dot) to do concatenation doesn't work,&amp;nbsp; I also tried&amp;nbsp;ENT_CallType + $t_CallType|s$,&amp;nbsp; it doesn't work either.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;| where ENT_CallType=if($t_CallType|s$ == "*",ENT_CallType,ENT_CallType.&lt;/SPAN&gt;&lt;SPAN&gt;$t_CallType|s$)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kevin&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sat, 22 Jan 2022 06:16:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Where-clause-has-syntax-error/m-p/582122#M47703</guid>
      <dc:creator>wangkevin1029</dc:creator>
      <dc:date>2022-01-22T06:16:57Z</dc:date>
    </item>
  </channel>
</rss>

