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
Ultra Champion

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
Ultra Champion

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
Ultra Champion

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!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...