Splunk Search

How to get the sum of some particular row in a separate row at the end of the table?

pal_sumit1
Path Finder

team12 sum1
atgbc.im 10
bctgd.im 20
cdtgb.im 30
abrfc.in 40
bcded.in 50
total (.im) 60
total (.in) 90
total(in+im)150

Fields names are "name" and "sum"."Team12" is the name of the list having all (.in and .im files)
We have to figure out how to calculate total(.im) and total(.in)?

Tags (2)
0 Karma
1 Solution

somesoni2
Revered Legend

You would use appendpipe command like this:

your current search giving field name and sum
| appendpipe [| where like(name,"%.im") | eval name="total (.im)" | stats sum(sum) as sum by name]
| appendpipe [| where like(name,"%.in") | eval name="total (.in)" | stats sum(sum) as sum by name]
| appendpipe [| where like(name,"total%") | eval name="total all" | stats sum(sum) as sum by name]

View solution in original post

somesoni2
Revered Legend

You would use appendpipe command like this:

your current search giving field name and sum
| appendpipe [| where like(name,"%.im") | eval name="total (.im)" | stats sum(sum) as sum by name]
| appendpipe [| where like(name,"%.in") | eval name="total (.in)" | stats sum(sum) as sum by name]
| appendpipe [| where like(name,"total%") | eval name="total all" | stats sum(sum) as sum by name]

pal_sumit1
Path Finder

THE CODE YOU HAVE WRITTEN IS CORRECT AND IT IS WORKING FINE.
I will extend this problem, Suppose we have a drop-down in dashboard having three option,1- total all,2-total-(.im) 3- total-(.in).So if we select option -1 then It should display all the individual team ,total(im),total(in),total.
if we select option -2 then it should display only (.im) teams and total(.im) and similarly if we select 3 option,it should display all (.in) team and total(.in).

Can we implement this using only one search?

I have used three search for that but want to implement it using only one.

0 Karma

somesoni2
Revered Legend

You can. Your dropdown token value should be
1. * for option 1 - total all
2. *(im)* for option 2- 2-total-(.im)
3. *(in)* for option 2- 2-total-(.in)

And your search should be this

 your current search giving field name and sum
 | appendpipe [| where like(name,"%.im") | eval name="total (.im)" | stats sum(sum) as sum by name]
 | appendpipe [| where like(name,"%.in") | eval name="total (.in)" | stats sum(sum) as sum by name]
 | appendpipe [| where like(name,"total%") | eval name="total all" | stats sum(sum) as sum by name]
 | search name="$DropdownTokenName$"
0 Karma

pal_sumit1
Path Finder

Yeah ,It is working fine.
Thanks

0 Karma
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

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