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!

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...