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
Get Updates on the Splunk Community!

.conf25 Community Recap

Hello Splunkers, And just like that, .conf25 is in the books! What an incredible few days — full of learning, ...

Splunk App Developers | .conf25 Recap & What’s Next

If you stopped by the Builder Bar at .conf25 this year, thank you! The retro tech beer garden vibes were ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...