Dashboards & Visualizations

Create a new field for the Total from a addtotals command

johnward4
Communicator

I'm trying to create a bar graph that displays the count(tickets) by group and then the TOTAL count of all tickets for the groups.

I'm currently using |addtotals to calculate the Total but I would like to create a new field to store that number. Right now I'm getting the Total showing under my Groups field. Ideally, I'd like to be able to use the new field for Total to show as a different color or overlay. I can't quite find what I'm looking for and it seems like others have asked about this.

index=test Groups=* 
| dedup Tickets
| chart count(Tickets) by Groups
| rename count(Tickets) as Tickets
| sort - Tickets
| addcoltotals Tickets
| fillnull value="TOTAL"
0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

Try like this. This will give field TOTAL as separate bar (in different color). You can also use it as overlay field.

index=test Groups=* 
 | dedup Tickets
 | chart count(Tickets) by Groups
 | rename count(Tickets) as Tickets
 | sort - Tickets
 | eventstats sum(Tickets) as TOTAL

View solution in original post

0 Karma

johnward4
Communicator

alt text

EXAMPLE of my graph

0 Karma

somesoni2
SplunkTrust
SplunkTrust

Try like this. This will give field TOTAL as separate bar (in different color). You can also use it as overlay field.

index=test Groups=* 
 | dedup Tickets
 | chart count(Tickets) by Groups
 | rename count(Tickets) as Tickets
 | sort - Tickets
 | eventstats sum(Tickets) as TOTAL
0 Karma

johnward4
Communicator

That gives me the total tickets for each Group as a separate colored bar but what I'm looking for is the total of all groups in one separate column called Total.

That's why addtotals came to mind as a way to calculate the number I need but I'm having trouble creating a new field with the Total.

0 Karma

somesoni2
SplunkTrust
SplunkTrust

It is going to give you total of all groups. Since we're adding a new column for total it comes with all group but its actually sum of all. Having it as additional column will allow you to do chart overlay.

0 Karma

johnward4
Communicator

Thank you. In the new field 'TOTAL' I see the correct calculation but instead of it writting once, I see the total calculation written over and over for each line that I have a group. This will confuse my users when they hover over the overlay and it still says

GroupName : Infrastructure
TOTAL : 9,090 <----- that's the right number but is there a way to remove the GroupName in this new field?

0 Karma

johnward4
Communicator

@somesoni2 any ideas on how to remove the groupname from my total overlay?

0 Karma

somesoni2
SplunkTrust
SplunkTrust

Since it's overlay field, it'll be available for all group names (all rows). What you can do is to rename the field TOTAL to say "ALL Group's Total" so that it's less confusing.

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

Splunk is officially part of Cisco

Revolutionizing how our customers build resilience across their entire digital footprint.   Splunk ...

Splunk APM & RUM | Planned Maintenance March 26 - March 28, 2024

There will be planned maintenance for Splunk APM and RUM between March 26, 2024 and March 28, 2024 as ...