Splunk Search

AddColTotals & Percentage Column

behymejt2012
Path Finder

Hi Everyone,

I have an existing table that includes several columns filled with numeric values and one column that creates percentage based off several of the existing columns. When adding in addcoltotals at the end of the statement, it adds the numeric columns correctly, but it adds all the percentage column values together.

Is there a way to have that addcoltotals percentage column be an average percentage total instead of an overall sum of all percentage?

Tags (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi behymejt2012,
using addcoltotals command you can specify the field list that you want to summarize

see the example in Splunk Documentation page http://docs.splunk.com/Documentation/Splunk/6.5.0/SearchReference/Addcoltotals

sourcetype=access_* | table userId bytes avgTime duration | addcoltotals bytes duration

Bye.
Giuseppe

0 Karma

Kyle_Jackson
Explorer

Figured it out, I had the same problem.
Add all the columns EXCEPT for the percentage column.
You should now have all totals except for the percentage column.
Do an eval looking for the null percentage column and calculate the percentage.

   ... | yoursearch | addcoltotals twomonth_job_failures twomonth_job_runs labelfield="myfield" | eval OneMonthPercentage=if(isnull(OneMonthPercentage), round((twomonth_job_failures/twomonth_job_runs)*100,2) , OneMonthPercentage)

lguinn2
Legend

You can't do that with addcoltotals. However, you can do something like this

yoursearchhere
| addcoltotals field1 field2 field3

where field1 field2 field3 is a list of the fields that you want to total.

demkic
Explorer

Hi there,
Is there a way that I can divide the values from field1 by the column total of field1 and display in a new field4? thank you

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...