Splunk Search

How to add a + or - sign before percent?

jip31
Motivator

hi

i add a + or a - sign before a percent result like this

 

| eval perc=if(s<2,"-","+").round((s/2)*100,1). "% " 

 

 But I need to substract 100 to the percentage result like below

 

| eval perc=if(sam<sam2,"-","+").round(100-(sam/sam2)*100,1). "% " 

 

but when I do this, I have + and - before the percent result

jip31_0-1651835574053.png

 

how to avoid this please?

 

Tags (1)
0 Karma
1 Solution

isoutamo
SplunkTrust
SplunkTrust

You can use function abs like

| eval perc=if(sam<sam2,"-","+").abs(round(100-(sam/sam2)*100,1)). "% " 

r. Ismo 

View solution in original post

0 Karma

isoutamo
SplunkTrust
SplunkTrust

You can use function abs like

| eval perc=if(sam<sam2,"-","+").abs(round(100-(sam/sam2)*100,1)). "% " 

r. Ismo 

0 Karma
Get Updates on the Splunk Community!

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...

Splunk App Dev Community Updates – What’s New and What’s Next

Welcome to your go-to roundup of everything happening in the Splunk App Dev Community! Whether you're building ...

The Latest Cisco Integrations With Splunk Platform!

Join us for an exciting tech talk where we’ll explore the latest integrations in Cisco &#43; Splunk! We’ve ...