<?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 Why doesn't a &amp;gt; WHERE clause work when an = does? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-a-gt-WHERE-clause-work-when-an-does/m-p/485971#M135965</link>
    <description>&lt;P&gt;I cannot seem to get my search to return results when comparing a property with a greater than comparison even though using an equals comparison does work.  The 'elements' property in my message is a 0 - x property of the event...meaning it could exist zero times or it could exist multiple times...each element in the event has a 'y' value.&lt;/P&gt;

&lt;P&gt;What i'm trying to accomplish is to count each time an event occurs where any of the elements in the event have a y value greater than a value.&lt;/P&gt;

&lt;P&gt;example:&lt;/P&gt;

&lt;P&gt;This search returns 2 :&lt;BR /&gt;
index="lab" source="*-test" | eval y='line.message.space-document.design.elements{}.y' | where y="1664" | stats count&lt;/P&gt;

&lt;P&gt;This search  returns 0 when it should be the same if not more than the above search:&lt;BR /&gt;
index="lab" source="*-test" | eval y='line.message.space-document.design.elements{}.y' | where y&amp;gt;"1663" | stats count&lt;/P&gt;</description>
    <pubDate>Fri, 15 Nov 2019 20:24:09 GMT</pubDate>
    <dc:creator>47024</dc:creator>
    <dc:date>2019-11-15T20:24:09Z</dc:date>
    <item>
      <title>Why doesn't a &gt; WHERE clause work when an = does?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-a-gt-WHERE-clause-work-when-an-does/m-p/485971#M135965</link>
      <description>&lt;P&gt;I cannot seem to get my search to return results when comparing a property with a greater than comparison even though using an equals comparison does work.  The 'elements' property in my message is a 0 - x property of the event...meaning it could exist zero times or it could exist multiple times...each element in the event has a 'y' value.&lt;/P&gt;

&lt;P&gt;What i'm trying to accomplish is to count each time an event occurs where any of the elements in the event have a y value greater than a value.&lt;/P&gt;

&lt;P&gt;example:&lt;/P&gt;

&lt;P&gt;This search returns 2 :&lt;BR /&gt;
index="lab" source="*-test" | eval y='line.message.space-document.design.elements{}.y' | where y="1664" | stats count&lt;/P&gt;

&lt;P&gt;This search  returns 0 when it should be the same if not more than the above search:&lt;BR /&gt;
index="lab" source="*-test" | eval y='line.message.space-document.design.elements{}.y' | where y&amp;gt;"1663" | stats count&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 20:24:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-a-gt-WHERE-clause-work-when-an-does/m-p/485971#M135965</guid>
      <dc:creator>47024</dc:creator>
      <dc:date>2019-11-15T20:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't a &gt; WHERE clause work when an = does?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-a-gt-WHERE-clause-work-when-an-does/m-p/485972#M135966</link>
      <description>&lt;P&gt;Splunk doesn't support greater-than / less-than with strings.  If y is a number then use &lt;CODE&gt;... | where y&amp;gt;1663 | ...&lt;/CODE&gt;.  If y is a string use &lt;CODE&gt;tonumber()&lt;/CODE&gt; to convert it.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 21:13:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-a-gt-WHERE-clause-work-when-an-does/m-p/485972#M135966</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-11-15T21:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't a &gt; WHERE clause work when an = does?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-a-gt-WHERE-clause-work-when-an-does/m-p/485973#M135967</link>
      <description>&lt;P&gt;Thank you for the suggestion...however when taking the string aspect away, it actually returns 0 results with both equals and greater comparisons.  I changed to below and still get 0 results when I should get at least 2.&lt;/P&gt;

&lt;P&gt;index="lab" source="*-test" | eval y=tonumber('line.message.space-document.design.elements{}.y') | where y&amp;gt;1663 | stats count&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 21:17:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-a-gt-WHERE-clause-work-when-an-does/m-p/485973#M135967</guid>
      <dc:creator>47024</dc:creator>
      <dc:date>2019-11-15T21:17:53Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't a &gt; WHERE clause work when an = does?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-a-gt-WHERE-clause-work-when-an-does/m-p/485974#M135968</link>
      <description>&lt;P&gt;Can you share some sample data?  Have you tried the second part of my answer (tonumber())?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 23:55:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-a-gt-WHERE-clause-work-when-an-does/m-p/485974#M135968</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-11-15T23:55:24Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't a &gt; WHERE clause work when an = does?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-a-gt-WHERE-clause-work-when-an-does/m-p/485975#M135969</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;index="lab" source="*-test" 
| eval y='line.message.space-document.design.elements{}.y' 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It seems that there are multiple y values.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="lab" source="*-test" 
| eval y='line.message.space-document.design.elements{}.y' 
| eval y=mvindex(y,0)
| stats count(eval(y &amp;gt; 1663)) as count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 16 Nov 2019 00:09:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-a-gt-WHERE-clause-work-when-an-does/m-p/485975#M135969</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2019-11-16T00:09:37Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't a &gt; WHERE clause work when an = does?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-a-gt-WHERE-clause-work-when-an-does/m-p/485976#M135970</link>
      <description>&lt;P&gt;If y is multivalue, then things get complicated. If you do a &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| table y
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;do you get a single value field for y in all cases, or multivalue? &lt;/P&gt;

&lt;P&gt;If you want to filter where any mv value &amp;gt; 1663, then you need to use mvfilter, e.g.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval y=mvappend("100","200","300","400","2000","500")
| eval x=mvfilter(y&amp;gt;1663)
| where mvcount(x)&amp;gt;0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;in this case, it will satisfy the condition, but this will not&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval y=mvappend("100","200","300","400","1000","500")
| eval x=mvfilter(y&amp;gt;1663)
| where mvcount(x)&amp;gt;0
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 16 Nov 2019 00:27:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-a-gt-WHERE-clause-work-when-an-does/m-p/485976#M135970</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2019-11-16T00:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: Why doesn't a &gt; WHERE clause work when an = does?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-a-gt-WHERE-clause-work-when-an-does/m-p/485977#M135971</link>
      <description>&lt;P&gt;This worked!  Thank you very much!&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2019 19:49:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-a-gt-WHERE-clause-work-when-an-does/m-p/485977#M135971</guid>
      <dc:creator>47024</dc:creator>
      <dc:date>2019-11-18T19:49:40Z</dc:date>
    </item>
  </channel>
</rss>

