Splunk Search

How to keep null results from Stats Count by field to match the whole table

angelcat
Engager

I have 4 types of devices, a column for total number, and I need to count by type. But some of the result are null, then it will skip the types with null values. How can I keep the null value to make the results match the types? Below is the expected result:

Type Total Count
A 10 null
B 20 null
C 30 5
D 40 6

I can only get the result like this:

Type Total Count
A 10 5
B 20 6
C 30

D 40

I have tried fillnull before and after count , but it does not work.

Tags (1)
0 Karma
1 Solution

somesoni2
Revered Legend

Try like this

index="scan" 
|stats count as Total by Type 
| append [search index=vm |join type=outer ip [search
index="scan" |fields Type ip]
|stats count by Type]
| stats values(Total) as Total values(count) as count by Type

View solution in original post

somesoni2
Revered Legend

Try like this

index="scan" 
|stats count as Total by Type 
| append [search index=vm |join type=outer ip [search
index="scan" |fields Type ip]
|stats count by Type]
| stats values(Total) as Total values(count) as count by Type

richgalloway
SplunkTrust
SplunkTrust

Please share your query.

---
If this reply helps you, Karma would be appreciated.
0 Karma

angelcat
Engager

index="scan"
|stats count as Total by Type
|appendcols [search index=vm |join type=outer ip [search
index="scan" |fields Type ip]
|stats count by Type

]
|table Type Total count

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 ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...