<?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: Decimal value comparison in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-result-string-having-Decimal-value/m-p/589005#M205125</link>
    <description>&lt;P&gt;How could I get the max version number from the input file ?&lt;/P&gt;</description>
    <pubDate>Tue, 15 Mar 2022 03:04:28 GMT</pubDate>
    <dc:creator>Kirank007</dc:creator>
    <dc:date>2022-03-15T03:04:28Z</dc:date>
    <item>
      <title>How to compare the result string having Decimal value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-result-string-having-Decimal-value/m-p/589002#M205122</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="IMG-20220314-WA0020.jpg" style="width: 1599px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/18495i2457B1B6E6CB60FC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="IMG-20220314-WA0020.jpg" alt="IMG-20220314-WA0020.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm unable to compare the result string which is having version(decimal value). While I'm using "If" condition it is not comparing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the above required output should be compliant... please help me with this.&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 03:16:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-result-string-having-Decimal-value/m-p/589002#M205122</guid>
      <dc:creator>Kirank007</dc:creator>
      <dc:date>2022-03-15T03:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: Decimal value comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-result-string-having-Decimal-value/m-p/589003#M205123</link>
      <description>&lt;P&gt;You have a number of issues:&lt;/P&gt;&lt;P&gt;You driver version is a string, so max() will take the max from a text based point of view, not numeric.&lt;/P&gt;&lt;P&gt;Your stats command will ONLY result in a single field as stats does aggregation so will only leave you the MaxDriverVersion field.&lt;/P&gt;&lt;P&gt;Your statement if (DriverVersion = "MaxDriverVersion" ...) is asking if the DriverVersion field (which does not exist due to stats command) is equal to the string&amp;nbsp;MaxDriverVersion.&lt;/P&gt;&lt;P&gt;You could used 'eventstats...' instead of stats command in which case you would have the DriverVersion field remaining. That would give you part of what you want - but the max issue is still signigicant, e.g.&lt;/P&gt;&lt;P&gt;comparing version 30.0.100.9805 and&amp;nbsp;version 30.0.99.9805.&lt;/P&gt;&lt;P&gt;30.0.99.9805 would be the max() of those two values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 02:01:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-result-string-having-Decimal-value/m-p/589003#M205123</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-03-15T02:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: Decimal value comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-result-string-having-Decimal-value/m-p/589005#M205125</link>
      <description>&lt;P&gt;How could I get the max version number from the input file ?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 03:04:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-result-string-having-Decimal-value/m-p/589005#M205125</guid>
      <dc:creator>Kirank007</dc:creator>
      <dc:date>2022-03-15T03:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: Decimal value comparison</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-result-string-having-Decimal-value/m-p/589019#M205132</link>
      <description>&lt;P&gt;If you want to get a version number out of the dotted version numbers, this is one example tecnique&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| fields - _time
| eval versionNumber=split("30.0.100.9805,30.0.99.9805,2.10.0.60,1.90,2.17.0.9.53.176,172.3.4,172.3.40.199", ",")
| mvexpand versionNumber
| rex field=versionNumber "(?&amp;lt;t_v5&amp;gt;\d+)\.?((?&amp;lt;t_v4&amp;gt;\d+))?\.?((?&amp;lt;t_v3&amp;gt;\d+))?\.?((?&amp;lt;t_v2&amp;gt;\d+))?\.?((?&amp;lt;t_v1&amp;gt;\d+))?\.?((?&amp;lt;t_v0&amp;gt;\d+))?"
| foreach t_v* [ eval t_value=(pow(10, (&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;-3) * 3)) * &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; + coalesce(t_value, 0) ]
| eval rounded_value=round(t_value, 9)
| sort t_value t_v5 t_v4 t_v3 t_v2 t_v1 t_v0
| table versionNumber t_value rounded_value&lt;/LI-CODE&gt;&lt;P&gt;Up to the mvexpand is the example setup&lt;/P&gt;&lt;P&gt;What's useful for you is rex/foreach/eval 3 lines. t_value will give you a version number as a decimal number that can be compared numerically with other numbers, so for your case&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Your search...
| rex field=DriverVersion "(?&amp;lt;t_v5&amp;gt;\d+)\.?((?&amp;lt;t_v4&amp;gt;\d+))?\.?((?&amp;lt;t_v3&amp;gt;\d+))?\.?((?&amp;lt;t_v2&amp;gt;\d+))?\.?((?&amp;lt;t_v1&amp;gt;\d+))?\.?((?&amp;lt;t_v0&amp;gt;\d+))?"
| foreach t_v* [ eval version=(pow(10, (&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;-3) * 3)) * &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; + coalesce(version, 0) ]
| eval rounded_value=round(version, 9)
| fields - t_v*
| eventstats max(dv) as max_dv
| eval ComplianceStatus=if(dv = max_dv, "Compliant", "NonCompliant")&lt;/LI-CODE&gt;&lt;P&gt;Note that all this is telling you is that the driver version is the same as the highest one in the file - does that mean compliance to you? What if none are compliant? This does not handle this case.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 05:35:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-compare-the-result-string-having-Decimal-value/m-p/589019#M205132</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2022-03-15T05:35:14Z</dc:date>
    </item>
  </channel>
</rss>

