Splunk Search

if-else condition

abhayneilam
Contributor

Can I use like this :

| eval a=if(Location!=" ",stat count by Location)

but I am getting error..

actually I want to find..I want to get the count for those records which are non-blank

Please help

Tags (2)
0 Karma

yannK
Splunk Employee
Splunk Employee

I am not sure that you can use conditional searches, just conditional field calculation using eval.

another way is to make sure that the field location exits, then count
| WHERE NOT ( Location=" " OR isnull(Location) ) | stat count by Location

0 Karma

Ayn
Legend

You could also include it in the stats command directly:

stats count(eval(Location==" " OR isnull(Location))
0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

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

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...