Splunk Search

Add 2 columns in a table on applied condition

nivethainspire_
Explorer

I have 3 columns in a table as below.
I need to sum two colums(mag and depth) if place="7km W of Cobb,california" or "1km se of loma linda,california".
show the result in mag and make depth as 0 column as 0 on applied condition(place).alt text

my result should be as follows:
alt text
Please help me to make a query for my condition.

0 Karma
1 Solution

gokadroid
Motivator
your Base query to generate place , mag, depth
| eval mag=if(place="7km W of Cobb, California" OR place="1km SE of Loma Linda, California", mag+depth, mag)
| eval depth=if(place="7km W of Cobb, California" OR place="1km SE of Loma Linda, California", 0, depth)
| table place, mag, depth

View solution in original post

0 Karma

gokadroid
Motivator
your Base query to generate place , mag, depth
| eval mag=if(place="7km W of Cobb, California" OR place="1km SE of Loma Linda, California", mag+depth, mag)
| eval depth=if(place="7km W of Cobb, California" OR place="1km SE of Loma Linda, California", 0, depth)
| table place, mag, depth
0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...