Splunk Search

How to create a condition statement

dkdeepshikhaa
Explorer

Is there a possibility in Splunk to get data like below :

If a condition is true then that data is to be printed in table 

If (a $lt; b)

eval c=round(((b-a)/b)*100),0)

print c (in table format)

Or else just a message on full screen that with "no change".

0 Karma

Vijeta
Influencer

@dkdeepshikhaa if there are multiple events in your query your conditional evaluation will be based on each event. You can get no change text in table with below query-

<your search>| eval var=round(((b-a)/b)*100),0) | eval c = if(a<b,var,"no change") | table c

vnravikumar
Champion
0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...