Splunk Search

Calculate percentage increase/reduction

superisk
Explorer

Hello,

I have calculated my Total Escalations per Quarter using stats count and I would like to include another field to calculate the percentage increase/decrease of Total Escalations per Quarter.

My query -

| inputlookup Case_Database_v2.csv
| rename "Case Number" AS Case_Number
| search Role=Support Squad=*CMS*
| lookup EAS_Escalations_v1.csv "Case Number" AS Case_Number OUTPUTNEW "Case Number"
| rename "Case Number" AS EAS_Case_Number
| eventstats dc(Case_Number) as CaseCount by Quarter
| stats count(EAS_Case_Number) as Total_Escalations by Quarter, CaseCount
| eval EAS_Escalation(Percentage)=round(Distinct_Escalations/CaseCount*100,2)

 

And this shows -

 

   
QuarterCaseCountTotal Escalations
Qtr 1799315
Qtr 2889368
Qtr 3798287
Qtr 4777220

 

I would like to calculate the percentage reduction per quarter, for example,  Qtr 4 Total Escalations of 220 is a 13.5% reduction on the 287 escalations from Qtr 3.

Any help is much appreciated!

Labels (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Streamstats should do it.

| inputlookup Case_Database_v2.csv
| rename "Case Number" AS Case_Number
| search Role=Support Squad=*CMS*
| lookup EAS_Escalations_v1.csv "Case Number" AS Case_Number OUTPUTNEW "Case Number"
| rename "Case Number" AS EAS_Case_Number
| eventstats dc(Case_Number) as CaseCount by Quarter
| stats count(EAS_Case_Number) as Total_Escalations by Quarter, CaseCount
| eval EAS_Escalation(Percentage)=round(Distinct_Escalations/CaseCount*100,2)
| streamstats window=2 range(Total_Escalations) as Diff
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Streamstats should do it.

| inputlookup Case_Database_v2.csv
| rename "Case Number" AS Case_Number
| search Role=Support Squad=*CMS*
| lookup EAS_Escalations_v1.csv "Case Number" AS Case_Number OUTPUTNEW "Case Number"
| rename "Case Number" AS EAS_Case_Number
| eventstats dc(Case_Number) as CaseCount by Quarter
| stats count(EAS_Case_Number) as Total_Escalations by Quarter, CaseCount
| eval EAS_Escalation(Percentage)=round(Distinct_Escalations/CaseCount*100,2)
| streamstats window=2 range(Total_Escalations) as Diff
---
If this reply helps you, Karma would be appreciated.

superisk
Explorer

Thank you kindly!

0 Karma
Get Updates on the Splunk Community!

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...