Splunk Dev

How do I do a nested if statement?

jitin_ratra
New Member

I am trying to use multiple ifs within the eval but the query seems to throw an error.

What i want to do is use TTI if it's greater than 0. Otherwise, I'd use TTIVR if FCP!=0

This is what i tried so far
| eval test=if( TTI > 0, TTI, if(FCP!=0,TTIVR))

0 Karma
1 Solution

Vijeta
Influencer

Use this code , as you need to specify the value if FCP!=0 condition is false therefore I have placed null( can be any other value like " ")

|eval test=if(TTI > 0, TTI,if(FCP!=0,TTIVR,null))

View solution in original post

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@jitin_ratra

You can try case also.

YOUR_SEARCH
| eval test=case( TTI>0, TTI, FCP!=0,TTIVR)

Sample Search:

| makeresults 
| eval TTI=100,FCP=0,TTIVR =100
| eval test=case( TTI>0, TTI, FCP!=0,TTIVR)

http://docs.splunk.com/Documentation/Splunk/7.2.0/SearchReference/ConditionalFunctions#case.28X.2C.2...

Vijeta
Influencer

Use this code , as you need to specify the value if FCP!=0 condition is false therefore I have placed null( can be any other value like " ")

|eval test=if(TTI > 0, TTI,if(FCP!=0,TTIVR,null))

0 Karma
Get Updates on the Splunk Community!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...