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!

Learn Splunk Insider Insights, Do More With Gen AI, & Find 20+ New Use Cases You Can ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Buttercup Games: Further Dashboarding Techniques (Part 7)

This series of blogs assumes you have already completed the Splunk Enterprise Search Tutorial as it uses the ...

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

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...