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!

Earn a $35 Gift Card for Answering our Splunk Admins & App Developer Survey

Survey for Splunk Admins and App Developers is open now! | Earn a $35 gift card!      Hello there,  Splunk ...

Continuing Innovation & New Integrations Unlock Full Stack Observability For Your ...

You’ve probably heard the latest about AppDynamics joining the Splunk Observability portfolio, deepening our ...

Monitoring Amazon Elastic Kubernetes Service (EKS)

As we’ve seen, integrating Kubernetes environments with Splunk Observability Cloud is a quick and easy way to ...