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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...