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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...