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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...