Dashboards & Visualizations

Why doesn't this if statement work for field coloring?

tkwaller1
Path Finder

I have an if statement in my dashboard code but it doesnt work and I have no idea why. Heres the code:

 

 

<row>
    <panel>
      <title>Submission Details</title>
      <table>
        <search>
          <query>index=my_db sourcetype="my:details"
| fillnull value="NA"  ID INT_MESSAGE_ID APPLICATION_NUMBER APPLICATION_TYPE SUBMISSION_NUMBER SUBMISSION_TYPE SUPPORTING_DOC_NUMBER GLOBAL_ID DUNS FEI PROJECT_ID MESSAGE_STATUS MESSAGE_COMMENT LAST_UPDATE_TIMESTAMP 
| stats count by ID INT_MESSAGE_ID APPLICATION_NUMBER APPLICATION_TYPE SUBMISSION_NUMBER SUBMISSION_TYPE SUPPORTING_DOC_NUMBER GLOBAL_ID DUNS FEI PROJECT_ID MESSAGE_STATUS MESSAGE_COMMENT LAST_UPDATE_TIMESTAMP 
| fields - count
| sort -INT_MESSAGE_ID</query>
          <earliest>$field1.earliest$</earliest>
          <latest>$field1.latest$</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="count">10</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">none</option>
        <option name="percentagesRow">false</option>
        <option name="refresh.display">progressbar</option>
        <option name="rowNumbers">false</option>
        <option name="totalsRow">false</option>
        <option name="wrap">true</option>
        <format type="color" field="MESSAGE_STATUS">
          <colorPalette type="expression">if (MESSAGE_COMMENT == "Processed", "#53A051", "#DC4E41")</colorPalette>
        </format>
      </table>
    </panel>
  </row>

 

 

 

 

Labels (4)
0 Karma
1 Solution

PickleRick
SplunkTrust
SplunkTrust

Yes. As I said, you can only refer to the value of the cell using the "value" argument. So you could use

if (value=="something", "#000000","#ffffff")

But that's not what you want because this colours a cell based on this cell's value, not other column.

Unfortunately the only way to do so is using external JS and CSS.

You can see how it's done in Dashboard Examples app https://splunkbase.splunk.com/app/1603

View solution in original post

0 Karma

PickleRick
SplunkTrust
SplunkTrust

I don't think you can simply colour one column's cell based on another column value with expression. With the expression color palette type you can only reference value of the cell you're colouring.

0 Karma

tkwaller1
Path Finder

I tried this just to test, 

<format type="color" field="MESSAGE_COMMENT">
          <colorPalette type="expression">if (MESSAGE_COMMENT="Processed","#53A051","#DC4E41") </colorPalette>
        </format>

 

It only colors the else portion. Like nothing meets the first condition. Even though 80% of my records are "Processed"

0 Karma

PickleRick
SplunkTrust
SplunkTrust

Yes. As I said, you can only refer to the value of the cell using the "value" argument. So you could use

if (value=="something", "#000000","#ffffff")

But that's not what you want because this colours a cell based on this cell's value, not other column.

Unfortunately the only way to do so is using external JS and CSS.

You can see how it's done in Dashboard Examples app https://splunkbase.splunk.com/app/1603

0 Karma

tkwaller1
Path Finder

Thanks,  sorry for not understanding hahaha. I follow now.

Thats exactly what I was looking for. It works now.

0 Karma
Get Updates on the Splunk Community!

How to Get Started with Splunk Data Management Pipeline Builders (Edge Processor & ...

If you want to gain full control over your growing data volumes, check out Splunk’s Data Management pipeline ...

Out of the Box to Up And Running - Streamlined Observability for Your Cloud ...

  Tech Talk Streamlined Observability for Your Cloud Environment Register    Out of the Box to Up And Running ...

Splunk Smartness with Brandon Sternfield | Episode 3

Hello and welcome to another episode of "Splunk Smartness," the interview series where we explore the power of ...