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?

 

Labels (1)
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!

Developer Spotlight with Paul Stout

Welcome to our very first developer spotlight release series where we'll feature some awesome Splunk ...

State of Splunk Careers 2024: Maximizing Career Outcomes and the Continued Value of ...

For the past four years, Splunk has partnered with Enterprise Strategy Group to conduct a survey that gauges ...

Data-Driven Success: Splunk & Financial Services

Splunk streamlines the process of extracting insights from large volumes of data. In this fast-paced world, ...