<?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: issue with Case statement when using multiple rex in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/issue-with-Case-statement-when-using-multiple-rex/m-p/212850#M13296</link>
    <description>&lt;P&gt;My guess is, its the $ sigh. Try removing that in your rex&lt;/P&gt;</description>
    <pubDate>Fri, 22 Apr 2016 22:01:56 GMT</pubDate>
    <dc:creator>sundareshr</dc:creator>
    <dc:date>2016-04-22T22:01:56Z</dc:date>
    <item>
      <title>issue with Case statement when using multiple rex</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/issue-with-Case-statement-when-using-multiple-rex/m-p/212849#M13295</link>
      <description>&lt;P&gt;I have the below search query which gives good result but when used in dashboard it says "Search is waiting for input",&lt;BR /&gt;
but when I remove the Rex from second statement it works in dashboard&lt;/P&gt;

&lt;P&gt;index=app-axxfer-restricted queryType="ts"&lt;BR /&gt;&lt;BR /&gt;
(&lt;BR /&gt;
  ((filename=RECON* NOT filename=RECON*.txt) "siteName=Send RECON file")  OR&lt;/P&gt;

&lt;P&gt;((filename=RECON* NOT filename=RECON*.txt) "siteName=Facets to Prod Mark") &lt;BR /&gt;
) &lt;BR /&gt;
|eval type =case(&lt;BR /&gt;
        (match(filename,"RECON+.\d+.\d+$") AND like(siteName,"%Send%")),"Files received from NASCO",&lt;BR /&gt;
     (match(filename,"RECON+.\d+.\d+$") AND like(siteName,"%Facets%")) , "FACETS Files sent to CVS"&lt;BR /&gt;&lt;BR /&gt;
)|timechart span=1d count by type&lt;/P&gt;

&lt;P&gt;this works only when I remove the rex as below...but this is No good for me&lt;BR /&gt;
 (match(filename,"RECON") AND like(siteName,"%Facets%")) , "FACETS Files sent to CVS"&lt;/P&gt;

&lt;P&gt;can you please tell me what to do for the Case statement so that it works in Dashboard even if I use multiple rex .&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2016 21:18:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/issue-with-Case-statement-when-using-multiple-rex/m-p/212849#M13295</guid>
      <dc:creator>prakashbhanu407</dc:creator>
      <dc:date>2016-04-22T21:18:09Z</dc:date>
    </item>
    <item>
      <title>Re: issue with Case statement when using multiple rex</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/issue-with-Case-statement-when-using-multiple-rex/m-p/212850#M13296</link>
      <description>&lt;P&gt;My guess is, its the $ sigh. Try removing that in your rex&lt;/P&gt;</description>
      <pubDate>Fri, 22 Apr 2016 22:01:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/issue-with-Case-statement-when-using-multiple-rex/m-p/212850#M13296</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-04-22T22:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: issue with Case statement when using multiple rex</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/issue-with-Case-statement-when-using-multiple-rex/m-p/212851#M13297</link>
      <description>&lt;P&gt;There are a couple of alternatives here to simplify the overall search string.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=app-axxfer-restricted queryType="ts" 
(
(filename=RECON* NOT filename=RECON*.txt "siteName=Send RECON file") OR
(filename=RECON* NOT filename=RECON*.txt "siteName=Facets to Prod Mark") 
) 
| eval type=case(
match(filename,"RECON+.\d+.\d+$") AND like(siteName,"Send%"),"Files received from NASCO",
match(filename,"RECON+.\d+.\d+$") AND like(siteName,"Facets%"), "FACETS Files sent to CVS",
1==1,"Unknown"
)
| timechart span=1d count by type
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you have tested the file name in the base search, you should not need to test it again in the eval - unless you want to eliminate more of the results. In the search above, I added a "catch-all" to the case statement to pick up any cases that don't match your pattern. But if you know that everything should match one of the first two cases, you can simplify further:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=app-axxfer-restricted queryType="ts" 
(filename=RECON* NOT filename=RECON*.txt "siteName=Send RECON file") OR
(filename=RECON* NOT filename=RECON*.txt "siteName=Facets to Prod Mark") 
| eval type=case(like(siteName,"Send%"),"Files received from NASCO",
            like(siteName,"Facets%"), "FACETS Files sent to CVS",
            1==1,"Unknown" )
| timechart span=1d count by type
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Although you could perhaps remove the third condition in the case statement - I wouldn't. It is a great way to catch something you might have missed.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Apr 2016 00:47:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/issue-with-Case-statement-when-using-multiple-rex/m-p/212851#M13297</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2016-04-23T00:47:55Z</dc:date>
    </item>
    <item>
      <title>Re: issue with Case statement when using multiple rex</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/issue-with-Case-statement-when-using-multiple-rex/m-p/212852#M13298</link>
      <description>&lt;P&gt;Thanks for the suggestion...but my search string has various other files too with the same "siteName" hence I had to use both "filename" and "sitename".&lt;/P&gt;</description>
      <pubDate>Sun, 24 Apr 2016 05:52:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/issue-with-Case-statement-when-using-multiple-rex/m-p/212852#M13298</guid>
      <dc:creator>prakashbhanu407</dc:creator>
      <dc:date>2016-04-24T05:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: issue with Case statement when using multiple rex</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/issue-with-Case-statement-when-using-multiple-rex/m-p/212853#M13299</link>
      <description>&lt;P&gt;thanks Sundar, it worked !!&lt;/P&gt;

&lt;P&gt;not sure why "$" worked when used in Search string but not in dashboard.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Apr 2016 05:54:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/issue-with-Case-statement-when-using-multiple-rex/m-p/212853#M13299</guid>
      <dc:creator>prakashbhanu407</dc:creator>
      <dc:date>2016-04-24T05:54:20Z</dc:date>
    </item>
    <item>
      <title>Re: issue with Case statement when using multiple rex</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/issue-with-Case-statement-when-using-multiple-rex/m-p/212854#M13300</link>
      <description>&lt;P&gt;Converted to an answer so it can be "Accepted" since this seemed to be the right answer.&lt;/P&gt;

&lt;P&gt;The explanation (I'd guess) is that $ is a special character in a dashboard and so maybe those two dollar signs were being interpreted as tokens and Splunk was trying to use &lt;CODE&gt;") AND like(siteName,"%Send%")),"Files received from NASCO", (match(filename,"RECON+.\d+.\d+&lt;/CODE&gt; as a variable with substitution (like &lt;CODE&gt;$time_tok&lt;/CODE&gt;).&lt;/P&gt;

&lt;P&gt;You MIGHT be able to escape each - &lt;CODE&gt;blah blah \$ blah blah&lt;/CODE&gt; to get around this as well.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Apr 2016 13:04:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/issue-with-Case-statement-when-using-multiple-rex/m-p/212854#M13300</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2016-04-24T13:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: issue with Case statement when using multiple rex</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/issue-with-Case-statement-when-using-multiple-rex/m-p/212855#M13301</link>
      <description>&lt;P&gt;I think you you escape with two &lt;CODE&gt;$&lt;/CODE&gt;, like this &lt;CODE&gt;$$&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2016 20:55:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/issue-with-Case-statement-when-using-multiple-rex/m-p/212855#M13301</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-04-26T20:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: issue with Case statement when using multiple rex</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/issue-with-Case-statement-when-using-multiple-rex/m-p/212856#M13302</link>
      <description>&lt;P&gt;It is a PCRE-type regular expression; I don't think you can escape one dollar sign with two. Proper regex syntax is that backslash is the escape character. But it looks like the dollar sign was unneeded anyway.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 22:18:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/issue-with-Case-statement-when-using-multiple-rex/m-p/212856#M13302</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2016-04-27T22:18:46Z</dc:date>
    </item>
  </channel>
</rss>

