Splunk Search

if else with where clause

dkdeepshikhaa
Explorer

required

if (a $lt; b)

eval c=round(((b-a)/b)*100),0)
print c
else
print "no change"

How to get this through splunk query?

1 Solution

vnravikumar
Champion

Hi

Try this

| makeresults 
| eval a=20,b=30 
| eval c=if(a<b,round(((b-a)/b)*100,0),"no change")

View solution in original post

vnravikumar
Champion

Hi

Try this

| makeresults 
| eval a=20,b=30 
| eval c=if(a<b,round(((b-a)/b)*100,0),"no change")

dkdeepshikhaa
Explorer

thank you vnravikumar, it worked

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@dkdeepshikhaa

Can you please try this?

| makeresults 
| eval a=100,b=20,c="No Change"
| eval c=case(a<b,round(((b-a)/b)*100,0),1=1,c)


| makeresults 
| eval a=100,b=200,c="No Change"
| eval c=case(a<b,round(((b-a)/b)*100,0),1=1,c)
0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...