Dashboards & Visualizations

field color change based on field value not working in dashboard

wangkevin1029
Communicator

Hi, Splunkers,

I have a field  duration in the panel, I added the following  <format></format> into the panel.

I want this duration field to show different color when it  is greater than 20.

but it doesn't work. 

<format type="color" field="duration">

          <colorPalette type="expression">if(tonumber(value)>20),"#789056")</colorPalette>

</format>

 

thx in advance.

 

Kevin

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

An if function requires 3 arguments if(condition, result if true, result if false) - you only have one, followed by a value outside the if function.

View solution in original post

wangkevin1029
Communicator

Hi, ITWhisperer

 

<colorPalette type="expression">if(tonumber(value)>20, "#789056","#009056")</colorPalette>

I put another color code here, it works.

However, here, I want to keep the original color , if   tonumber(value)>20  is false.

what value should I put here as color code for false?

 

besides, 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

An if function requires 3 arguments if(condition, result if true, result if false) - you only have one, followed by a value outside the if function.

wangkevin1029
Communicator

Hi, ITWhisperer,

 

it works when I just put a “” for false value, then it keeps original color.

<colorPalette type="expression">if(tonumber(value)>20, "#789056","")</colorPalette>

 

Kevin

 
0 Karma

wangkevin1029
Communicator

Btw, the original color in table is alternatively light/dark color every other line.

in this way, not sure how to specify the default color here.

 

Kevin

0 Karma
Get Updates on the Splunk Community!

Say goodbye to manually analyzing phishing and malware threats with Splunk Attack ...

In today’s evolving threat landscape, we understand you’re constantly bombarded with phishing and malware ...

AppDynamics is now part of Splunk Ideas

Hello Splunkers, We have exciting news for you! AppDynamics has been added to the Splunk Ideas Portal. Which ...

Advanced Splunk Data Management Strategies

Join us on Wednesday, May 14, 2025, at 11 AM PDT / 2 PM EDT for an exclusive Tech Talk that delves into ...