<?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: substr result in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/substr-result/m-p/368813#M169927</link>
    <description>&lt;P&gt;Thanks a lot for your explanation, that was really helpful&lt;/P&gt;</description>
    <pubDate>Fri, 27 Apr 2018 13:39:46 GMT</pubDate>
    <dc:creator>katouoma</dc:creator>
    <dc:date>2018-04-27T13:39:46Z</dc:date>
    <item>
      <title>substr result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/substr-result/m-p/368809#M169923</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;I'm trying to use substr to extract the first 4 characters of my result (perc_err_test1 &amp;amp; perc_err_test2), but i don't know how to do it : &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval Error = if(test1 &amp;gt; 2,1,0) | eval Erreur = if(test2 &amp;gt; 2,1,0) 
| stats count as TOTAL, sum(Erreur)  as Erreur_test1, sum(Error) as Error_test2 
| eval perc_err_test1 = (Erreur_test1 / TOTAL) * 100 ." %" | eval perc_err_test2 = (Error_test2 / TOTAL) * 100 ." %"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here is my result : &lt;BR /&gt;
&lt;IMG src="https://community.splunk.com/storage/temp/249577-substr.png" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:18:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/substr-result/m-p/368809#M169923</guid>
      <dc:creator>katouoma</dc:creator>
      <dc:date>2020-09-29T19:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: substr result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/substr-result/m-p/368810#M169924</link>
      <description>&lt;P&gt;What is the result you are after, based on this example? What have you tried and is not working?&lt;/P&gt;

&lt;P&gt;I'm guessing you actually want to round the precentage, rather than taking the first 4 characters?&lt;/P&gt;

&lt;P&gt;So: update your existing percentage calculating evals to look something like this: &lt;CODE&gt;| eval perc_err_test1 = round((Erreur_test1 / TOTAL) * 100,2) ." %"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;PS: you might want to look at alternative ways of adding that percentage sign. E.g. using &lt;CODE&gt;| fieldformat perc_err_test1=perc_err_test1." %"&lt;/CODE&gt; such that the original numerical values are preserved for better sorting etc.&lt;/P&gt;

&lt;P&gt;PPS: I took the liberty of editing your question, to put the search commands as code (using that 101010 button). That makes it easier to read and also prevents some special characters like &lt;CODE&gt;*&lt;/CODE&gt;  in this case from dissapearing &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 09:32:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/substr-result/m-p/368810#M169924</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-04-27T09:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: substr result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/substr-result/m-p/368811#M169925</link>
      <description>&lt;P&gt;Hi katouoma,&lt;/P&gt;

&lt;P&gt;Can you try using round instead:&lt;BR /&gt;
eval perc_err_test2 = round((Error_test2 / TOTAL) 100,4) ." %"&lt;/P&gt;

&lt;P&gt;Let me know if this helps!!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:18:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/substr-result/m-p/368811#M169925</guid>
      <dc:creator>deepashri_123</dc:creator>
      <dc:date>2020-09-29T19:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: substr result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/substr-result/m-p/368812#M169926</link>
      <description>&lt;P&gt;Can you try this please:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Error = if(test1 &amp;gt; 2,1,0) | eval Erreur = if(test2 &amp;gt; 2,1,0) 
 | stats count as TOTAL, sum(Erreur)  as Erreur_test1, sum(Error) as Error_test2 
 | eval perc_err_test1 = round((Erreur_test1 / TOTAL) * 100,2)."%" , perc_err_test2 =round( (Error_test2 / TOTAL) * 100,2)."%" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR if you want use subtr command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Error = if(test1 &amp;gt; 2,1,0) | eval Erreur = if(test2 &amp;gt; 2,1,0) 
 | stats count as TOTAL, sum(Erreur)  as Erreur_test1, sum(Error) as Error_test2 
 | eval perc_err_test1 =(Erreur_test1 / TOTAL) * 100,2) , perc_err_test2 =(Error_test2 / TOTAL) * 100,2) 
 | eval perc_err_test1=substr(perc_err_test1,1,5)."%", perc_err_test2=substr(perc_err_test2,1,5)."%"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Apr 2018 10:49:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/substr-result/m-p/368812#M169926</guid>
      <dc:creator>TISKAR</dc:creator>
      <dc:date>2018-04-27T10:49:57Z</dc:date>
    </item>
    <item>
      <title>Re: substr result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/substr-result/m-p/368813#M169927</link>
      <description>&lt;P&gt;Thanks a lot for your explanation, that was really helpful&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 13:39:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/substr-result/m-p/368813#M169927</guid>
      <dc:creator>katouoma</dc:creator>
      <dc:date>2018-04-27T13:39:46Z</dc:date>
    </item>
    <item>
      <title>Re: substr result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/substr-result/m-p/368814#M169928</link>
      <description>&lt;P&gt;Thank you @TISKAR this is exactly what i'm looking for (the first one using the "round" command)&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 13:42:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/substr-result/m-p/368814#M169928</guid>
      <dc:creator>katouoma</dc:creator>
      <dc:date>2018-04-27T13:42:11Z</dc:date>
    </item>
    <item>
      <title>Re: substr result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/substr-result/m-p/368815#M169929</link>
      <description>&lt;P&gt;Yeah this is the right answer but using : 100,3 rather than 100,4&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 13:44:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/substr-result/m-p/368815#M169929</guid>
      <dc:creator>katouoma</dc:creator>
      <dc:date>2018-04-27T13:44:58Z</dc:date>
    </item>
    <item>
      <title>Re: substr result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/substr-result/m-p/368816#M169930</link>
      <description>&lt;P&gt;Can you up vote please to help another person&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 13:51:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/substr-result/m-p/368816#M169930</guid>
      <dc:creator>TISKAR</dc:creator>
      <dc:date>2018-04-27T13:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: substr result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/substr-result/m-p/368817#M169931</link>
      <description>&lt;P&gt;Yes but how can I do it ? (I'm new here ..)&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 14:12:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/substr-result/m-p/368817#M169931</guid>
      <dc:creator>katouoma</dc:creator>
      <dc:date>2018-04-27T14:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: substr result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/substr-result/m-p/368818#M169932</link>
      <description>&lt;P&gt;In left you have zero betwen two arrow clic to up vote, Thank's&lt;/P&gt;</description>
      <pubDate>Fri, 27 Apr 2018 15:30:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/substr-result/m-p/368818#M169932</guid>
      <dc:creator>TISKAR</dc:creator>
      <dc:date>2018-04-27T15:30:14Z</dc:date>
    </item>
  </channel>
</rss>

