Splunk Search

question on eval and if in case of multiple validations

jiaqya
Builder

ex: if value1=1 and value2=2
then i should be able to eval value3 based on a comparison condition ( i.e value3>90,test,value3 )

is this possible or is there any workaround to achieve this ?

John.

Tags (2)
0 Karma

somesoni2
Revered Legend

The question may be confusing. Could you post some sudo code to describe what you're trying to achieve? Are you looking to do something like this?

...| eval value3=if(value1=1 AND value2=2,if(value3>90,test,value3),"SomeOtherDefaultValue")
0 Karma

MuS
Legend

Hi jiaqya,

try this:

... | eval new_value=case(value1="1" AND value2="2", value3, 1=1, "unknown")

or this:

... | eval new_value=if(value1="1" AND value2="2", value3, somethingelse)

Hope this helps ...

cheers, MuS

jiaqya
Builder

Hi, i realised i could do value1-value2 directly and get the difference and then i was able to set the value based on the difference..

value1 and value 2 were columns..
thanks for your responses, i could get to where i wanted to be..

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...