Dashboards & Visualizations

Single value color change based on condition?

Nic
Engager

Hi all

I have the following query for a single value visualisation:

 

 

| stats count(eval(completedDate < TargetDate)) as completed, count(number) as total
| eval percentage = round((completed/total)*100, 2)." %"

 

 

The visualisation is the percentage. I need to change the colors to red and green based on the value of the percentage. This I managed to do. However, I need to change the color of the value to grey if total<5. Is this possible to do, or not?

Thanks in advance.

Labels (2)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Yes, you have control over the colors in a SV.  Click on the format icon for the visualization then click on the Color tab on the left.  Enter the levels for each range and click on the colored box to choose the color for that range.  Use the "Add Range" button if you need more ranges.  Changes are saved when you close the formatter.

---
If this reply helps you, Karma would be appreciated.
0 Karma

Nic
Engager

Hi, Thank you for your quick reply. Unfortunately the output of this single value is not the 'total' value (numeric), but the 'percentage' value (string). I was wondering if I can change the color of the percentage value if the total value is <5.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

If the value is a string then it cannot be compared to a number.

The fix is to remove the "%" from the value and let the SV visualization add it in for you using the "Number Format" tab in the formatter.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...