Splunk Search

help on if condition for results = 0

jip31
Motivator

hello

In a panel table, I need to display every key_path even if the key_path result = 0
I have done an if condition but it doenst works
could you help me please??

index="toto" sourcetype="WinRegistry" key_path="HKLM\\software\\microsoft\\windows nt\\currentversion\\xx" OR key_path="HKLM\\software\\microsoft\\windows nt\\currentversion\\yy" OR key_path="HKLM\\software\\wow6432node\\zz" 
| stats dc(host) as test by sourcetype key_path 
| eval test=if(test==0,"0", test)
Tags (1)
0 Karma
1 Solution

kamlesh_vaghela
SplunkTrust
SplunkTrust

@jip31

Can you please try this?

index="toto" sourcetype="WinRegistry" key_path="HKLM\\software\\microsoft\\windows nt\\currentversion\\xx" OR key_path="HKLM\\software\\microsoft\\windows nt\\currentversion\\yy" OR key_path="HKLM\\software\\wow6432node\\zz" 
| stats dc(host) as count by sourcetype key_path | append [| makeresults | eval sourcetype="WinRegistry", count=0, key_path="HKLM\\software\\microsoft\\windows nt\\currentversion\\xx||HKLM\\software\\microsoft\\windows nt\\currentversion\\yy||HKLM\\software\\wow6432node\\zz",key_path=split(key_path,"||") | mvexpand key_path | table sourcetype key_path count] | stats sum(count) as count by sourcetype key_path

View solution in original post

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@jip31

Can you please try this?

index="toto" sourcetype="WinRegistry" key_path="HKLM\\software\\microsoft\\windows nt\\currentversion\\xx" OR key_path="HKLM\\software\\microsoft\\windows nt\\currentversion\\yy" OR key_path="HKLM\\software\\wow6432node\\zz" 
| stats dc(host) as count by sourcetype key_path | append [| makeresults | eval sourcetype="WinRegistry", count=0, key_path="HKLM\\software\\microsoft\\windows nt\\currentversion\\xx||HKLM\\software\\microsoft\\windows nt\\currentversion\\yy||HKLM\\software\\wow6432node\\zz",key_path=split(key_path,"||") | mvexpand key_path | table sourcetype key_path count] | stats sum(count) as count by sourcetype key_path
0 Karma

jip31
Motivator

hi its perfect thanks!

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

Great @jip31. Can you please upvote and accept this answer to close this question?

0 Karma
Get Updates on the Splunk Community!

Splunk Decoded: Service Maps vs Service Analyzer Tree View vs Flow Maps

It’s Monday morning, and your phone is buzzing with alert escalations – your customer-facing portal is running ...

What’s New in Splunk Observability – September 2025

What's NewWe are excited to announce the latest enhancements to Splunk Observability, designed to help ITOps ...

Fun with Regular Expression - multiples of nine

Fun with Regular Expression - multiples of nineThis challenge was first posted on Slack #regex channel ...