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!

[Puzzles] Solve, Learn, Repeat: Reprocessing XML into Fixed-Length Events

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

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...