<?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: How to sum the percentage of this two value in the table and rename it as X and show it in the table next to other values?! in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-percentage-of-this-two-value-in-the-table-and/m-p/463064#M146665</link>
    <description>&lt;P&gt;Edit:&lt;BR /&gt;
Oh wait . misunderstood the question &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Feb 2020 13:13:37 GMT</pubDate>
    <dc:creator>nickhills</dc:creator>
    <dc:date>2020-02-06T13:13:37Z</dc:date>
    <item>
      <title>How to sum the percentage of this two value in the table and rename it as X and show it in the table next to other values?!</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-percentage-of-this-two-value-in-the-table-and/m-p/463063#M146664</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8333i7F6F0060E36E40CD/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;BR /&gt;
As you can see in the picture there is 2 value (ChargeInProgress &amp;amp; Charging) which I know they are same (but whit the different name),&lt;BR /&gt;
So I wish to Sum the percentage of this two value and rename it as X and showi it in the table next to other values,&lt;/P&gt;

&lt;P&gt;I have try this :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"Set status * for charging point"
| rex "charging point\s*(?P&amp;lt;charging_point&amp;gt;.*)" 
| rex "Set status\s*(?P&amp;lt;status&amp;gt;.*?,*)\s" 
| eventstats sum(ChargeInProgress,Charging) as X
| dedup charging_point
| top limit=20 status 
| fields status, percent
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but not works, and same result :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;status                                        percent
Idle                                          71.397640
SuspendedEV                           11.518077
Charging                                  9.131379
ChargeInProgress                  4.996529
Preparing                                 1.456150
SuspendedEVSE                 0.547640
Error                                         0.442961
Finishing                                 0.386764
Unavailable                       0.122310
NotMonitored                          0.000551
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to see this as a result &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;status                                        percent
Idle                                          71.397640
X                                                 14.127908
SuspendedEV                           11.518077
Preparing                                 1.456150
SuspendedEVSE                 0.547640
Error                                         0.442961
Finishing                                 0.386764
Unavailable                       0.122310
NotMonitored                          0.000551
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Feb 2020 10:31:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-percentage-of-this-two-value-in-the-table-and/m-p/463063#M146664</guid>
      <dc:creator>aryamehr360</dc:creator>
      <dc:date>2020-02-06T10:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum the percentage of this two value in the table and rename it as X and show it in the table next to other values?!</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-percentage-of-this-two-value-in-the-table-and/m-p/463064#M146665</link>
      <description>&lt;P&gt;Edit:&lt;BR /&gt;
Oh wait . misunderstood the question &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2020 13:13:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-percentage-of-this-two-value-in-the-table-and/m-p/463064#M146665</guid>
      <dc:creator>nickhills</dc:creator>
      <dc:date>2020-02-06T13:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum the percentage of this two value in the table and rename it as X and show it in the table next to other values?!</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-percentage-of-this-two-value-in-the-table-and/m-p/463065#M146666</link>
      <description>&lt;P&gt;this is not working,&lt;BR /&gt;
CODE:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"Set status * for charging point"
  | rex "charging point\s*(?P&amp;lt;charging_point&amp;gt;.*)" 
  | rex "Set status\s*(?P&amp;lt;status&amp;gt;.*?,*)\s" 
  | eval X = ChargeInProgress+Charging
  | fields - ChargeInProgress,Charging
  | dedup charging_point
  | top limit=20 status 
  | fields status, percent
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Result :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;status  percent
Idle    66.026646
ChargeInProgress    24.098746
Charging    4.555251
SuspendedEV 3.389498
SuspendedEVSE   0.597571
Error   0.538793
Preparing   0.489812
Finishing   0.225313
Unavailable 0.068574
NotMonitored    0.009796
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Feb 2020 18:44:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-percentage-of-this-two-value-in-the-table-and/m-p/463065#M146666</guid>
      <dc:creator>aryamehr360</dc:creator>
      <dc:date>2020-02-06T18:44:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum the percentage of this two value in the table and rename it as X and show it in the table next to other values?!</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-percentage-of-this-two-value-in-the-table-and/m-p/463066#M146667</link>
      <description>&lt;P&gt;yeah, i misunderstood what you were initially asking, this would have produced a result, just not the one you were after:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"Set status * for charging point"
   | rex "charging point\s*(?P&amp;lt;charging_point&amp;gt;.*)" 
   | rex "Set status\s*(?P&amp;lt;status&amp;gt;.*?,*)\s" 
   | eval X = ChargeInProgress+Charging
   | fields - ChargeInProgress,Charging
   | dedup charging_point
   | top limit=20 status 
   | fields status, percent, X
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Feb 2020 18:53:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-percentage-of-this-two-value-in-the-table-and/m-p/463066#M146667</guid>
      <dc:creator>nickhills</dc:creator>
      <dc:date>2020-02-06T18:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum the percentage of this two value in the table and rename it as X and show it in the table next to other values?!</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-percentage-of-this-two-value-in-the-table-and/m-p/463067#M146668</link>
      <description>&lt;P&gt;No this is not working too see the result :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;status  percent             X
Idle    66.049679    
ChargeInProgress    24.379016    
Charging    4.325309     
SuspendedEV 3.366261     
SuspendedEVSE   0.604201     
Error   0.556248     
Preparing   0.450753     
Finishing   0.191810     
Unavailable 0.076724
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this add a field by X,&lt;BR /&gt;
I want to Sum the percentage of  "ChargeInProgress"24.379016 + "Charging":4.325309 = 28.704325 and show it in the table just with other status name for example: X,&lt;BR /&gt;
so I want this as a result :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;status  percent 
Idle    66.049679    
X          28.704325     
SuspendedEV 3.366261     
SuspendedEVSE   0.604201     
Error   0.556248     
Preparing   0.450753     
Finishing   0.191810     
Unavailable 0.076724
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Feb 2020 19:02:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-percentage-of-this-two-value-in-the-table-and/m-p/463067#M146668</guid>
      <dc:creator>aryamehr360</dc:creator>
      <dc:date>2020-02-06T19:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum the percentage of this two value in the table and rename it as X and show it in the table next to other values?!</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-percentage-of-this-two-value-in-the-table-and/m-p/463068#M146669</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;"Set status * for charging point" 
| rex "charging point\s*(?P&amp;lt;charging_point&amp;gt;.*)" 
| rex "Set status\s*(?P&amp;lt;status&amp;gt;.*?,*)\s" 
| eval status=case(status="Idle",status,like(status,"Charg%"),"X",true(),"others")
| dedup charging_point 
| top status 
| fields status, percent
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;H2&gt;That's enough.&lt;/H2&gt;

&lt;P&gt;Sample:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="status percent
Idle 71.397640
SuspendedEV 11.518077
Charging 9.131379
ChargeInProgress 4.996529
Preparing 1.456150
SuspendedEVSE 0.547640
Error 0.442961
Finishing 0.386764
Unavailable 0.122310
NotMonitored 0.000551" 
| multikv forceheader=1 
| table status percent 
 `comment("this is your result sample. from here, the logic")`
| transpose 0 header_field=status 
| eval X=Charging+ChargeInProgress 
| table Idle  X SuspendedEV SuspendedEVSE Preparing Error  Finishing  Unavailable NotMonitored
| transpose 0 column_name=status
| rename "row 1" as percent
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hi, folks. how about this?&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2020 02:30:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-percentage-of-this-two-value-in-the-table-and/m-p/463068#M146669</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-02-07T02:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum the percentage of this two value in the table and rename it as X and show it in the table next to other values?!</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-percentage-of-this-two-value-in-the-table-and/m-p/463069#M146670</link>
      <description>&lt;P&gt;Thank It workt, I also try to do some thing els to get the totaal percentage of this values :&lt;BR /&gt;
SuspendedEV, Preparing, Error, Finishing, SuspendedEVSE, Unavailable &lt;BR /&gt;
and show it as "others",&lt;/P&gt;

&lt;P&gt;So I want this as a result :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; status    percent    
 Idle    66.049679     
 X          28.704325     
others  5.245997
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I try that but not working:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"Set status * for charging point" 
| rex "charging point\s*(?P&amp;lt;charging_point&amp;gt;.*)" 
| rex "Set status\s*(?P&amp;lt;status&amp;gt;.*?,*)\s" 
| eval status=if(like(status,"Charg%"),"X",status)
| eval status=if(like(status,"SuspendedEV","Preparing","Error","Finishing","SuspendedEVSE","Unavailable"),"total",status)
| dedup charging_point 
| top limit=20 status
| fields status, percent
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 07 Feb 2020 10:59:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-percentage-of-this-two-value-in-the-table-and/m-p/463069#M146670</guid>
      <dc:creator>aryamehr360</dc:creator>
      <dc:date>2020-02-07T10:59:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum the percentage of this two value in the table and rename it as X and show it in the table next to other values?!</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-percentage-of-this-two-value-in-the-table-and/m-p/463070#M146671</link>
      <description>&lt;P&gt;@aryamehr360 &lt;BR /&gt;
I see, my answer is updated.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2020 11:16:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-percentage-of-this-two-value-in-the-table-and/m-p/463070#M146671</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-02-07T11:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum the percentage of this two value in the table and rename it as X and show it in the table next to other values?!</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-percentage-of-this-two-value-in-the-table-and/m-p/463071#M146672</link>
      <description>&lt;P&gt;Can you tell me what is the right command to get this as well; &lt;BR /&gt;
    status    percent&lt;BR /&gt;&lt;BR /&gt;
      Idle    66.049679&lt;BR /&gt;&lt;BR /&gt;
      X          28.704325&lt;BR /&gt;&lt;BR /&gt;
     others  5.245997&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2020 16:33:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-percentage-of-this-two-value-in-the-table-and/m-p/463071#M146672</guid>
      <dc:creator>aryamehr360</dc:creator>
      <dc:date>2020-02-07T16:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum the percentage of this two value in the table and rename it as X and show it in the table next to other values?!</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-percentage-of-this-two-value-in-the-table-and/m-p/463072#M146673</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| eval status=case(status="Idle",status,like(status,"Charg%"),"X",true(),"others")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;cf. &lt;A href="https://docs.splunk.com/Documentation/Splunk/8.0.1/SearchReference/ConditionalFunctions#case.28X.2C.22Y.22.2C....29"&gt;eval case() and true()&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;case()&lt;/CODE&gt; works from left side.&lt;BR /&gt;
As I don't want to write many args, everything else is selected with &lt;CODE&gt;true ()&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;In your first query, &lt;CODE&gt;like()&lt;/CODE&gt; has only two args and second arg is SQL-LIKE REGEX.&lt;BR /&gt;
 you should use other function. &lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2020 22:50:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-percentage-of-this-two-value-in-the-table-and/m-p/463072#M146673</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-02-07T22:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to sum the percentage of this two value in the table and rename it as X and show it in the table next to other values?!</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-percentage-of-this-two-value-in-the-table-and/m-p/463073#M146674</link>
      <description>&lt;P&gt;Great , Thanks a lot &lt;/P&gt;</description>
      <pubDate>Sat, 08 Feb 2020 11:06:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-sum-the-percentage-of-this-two-value-in-the-table-and/m-p/463073#M146674</guid>
      <dc:creator>aryamehr360</dc:creator>
      <dc:date>2020-02-08T11:06:21Z</dc:date>
    </item>
  </channel>
</rss>

