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!

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 ...