Splunk Search

Can we name the addcoltotals field in a bar chart?

vrmandadi
Builder

I ran this search:

.....| chart  count by TYPE | addcoltotals labelfield=total 

and got these results:

type    count     total
a         2
b         2
c         2          
          6       total

I visualized the above result in a bar chart, but the total field does not have any name to it like a or b or c .....is there any way that the bar chart can have a name called total?

0 Karma
1 Solution

ngatchasandra
Builder

Hi vrmandadi,

Try with fillnull command to have a name for it like follow in your bar graph

 .....| chart  count by TYPE | addcoltotals labelfield=total |fillnull value=TOTAL

Or you can try:

.....| chart  count by TYPE | addcoltotals labelfield=TYPE label=total

View solution in original post

maciep
Champion

haven't done any testing but what if you set labelfield to TYPE

.... | addcoltotals labelfield=TYPE

So that you end up with data that looks like this instead

TYPE       count
 a               2
 b               2
 c               2          
 total         6

Since you are chart'ing by TYPE, I don't think you'd see a new field you named total

0 Karma

ngatchasandra
Builder

Hi vrmandadi,

Try with fillnull command to have a name for it like follow in your bar graph

 .....| chart  count by TYPE | addcoltotals labelfield=total |fillnull value=TOTAL

Or you can try:

.....| chart  count by TYPE | addcoltotals labelfield=TYPE label=total

ngatchasandra
Builder

Thanks vrmandadi,

I see that you sent me also points. You could also do it by just vote has left my response

0 Karma

vrmandadi
Builder

thanks a lot the first query worked just with a small change

chart count by TYPE | addcoltotals labelfield=total |fillnull value=TOTAL |fields -total

0 Karma

gyslainlatsa
Motivator

hi,

try like this:

your base search | chart count by TYPE |addcoltotals labelfield=TOTAL label=Total
0 Karma

vrmandadi
Builder

This is same as the search i typed and the result is the same,,when I see the bar graph I cannot see the name for it

0 Karma

somesoni2
Revered Legend

Try something like this

your base search | chart count by TYPE | addcoltotals | eval TYPE=coalesce(TYPE,"total")

OR

your base search | chart count by TYPE | appendpipe [| stats sum(count) as count | eval TYPE="total"]

Updated
Total as separate series/column

  your base search | chart count by TYPE | eventstats sum(count) as total
0 Karma

vrmandadi
Builder

Hi Somesh,

I tried using the above two searches but none of them gave me name on the bar graph ,the second search adds all total and again adds the total with the above count.

0 Karma

somesoni2
Revered Legend

Both the search should give an output like this

type count
a         2
b         2
c         2 
total   6

Both column and bar chart gives me a bar/column with name total. I guess you're talking about the legend where the name of series is only count. If you want to have total as separate series, try the updated answer.

0 Karma

vrmandadi
Builder

| chart count by MESSAGE_TYPE | addcoltotals labelfield=total |fillnull value=TOTAL |fields- total

this worked...the updated query gives a separate column total and each row is having the the total

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!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

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 ...