Splunk Search

the function sum(count) by xx field is not working

umsundar2015
Path Finder

For me the below stats sum(count) by Asset_status provies no results .

eval Asset_status= if(Asset_Class=Server OR Asset_Type_Name=Server OR Asset_Class="" ,"Server",if( Asset_Class="eskto" OR Asset_Type_Name=Computer OR Asset_Type_Name="","Desktop","Others"))|stats sum(count) by Asset_status

Asset_status sum(count)
Desktop

Others

Server

May i please know the reason for this and how can i get the sum of counts values.

Tags (1)
0 Karma
1 Solution

inventsekar
SplunkTrust
SplunkTrust

stats sum(count) is not needed. just stats count is fine.

    |stats count by Asset_status

eval Asset_status= if(Asset_Class=Server OR Asset_Type_Name=Server OR Asset_Class="" ,"Server",if( Asset_Class="eskto" OR Asset_Type_Name=Computer OR Asset_Type_Name="","Desktop","Others"))|stats count by Asset_status 

View solution in original post

0 Karma

inventsekar
SplunkTrust
SplunkTrust

stats sum(count) is not needed. just stats count is fine.

    |stats count by Asset_status

eval Asset_status= if(Asset_Class=Server OR Asset_Type_Name=Server OR Asset_Class="" ,"Server",if( Asset_Class="eskto" OR Asset_Type_Name=Computer OR Asset_Type_Name="","Desktop","Others"))|stats count by Asset_status 
0 Karma

inventsekar
SplunkTrust
SplunkTrust

Hi Umsundar, may i know if this issue got resolved, can you please mark it as accepted answer..

0 Karma

cmerriman
Super Champion

also, you can use case instead of a nested if

...|eval Asset_status= case(Asset_Class=Server OR Asset_Type_Name=Server OR Asset_Class="" ,"Server", Asset_Class="eskto" OR Asset_Type_Name=Computer OR Asset_Type_Name="","Desktop",1=1,"Others")|stats count by Asset_status
0 Karma
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...