Dashboards & Visualizations

How to color the table cell based on other column cell value?

vn86893
Explorer

I have two columns in a table host and status

my status column has value 200 and 404

So based on the status column on every host i want to color the host cell.

i don't want to color status cell or display it. I just want to display host filed and it should be colored based on status value.

Labels (1)
0 Karma

jijulukose
Explorer

I was looking for a solution to similar problem and came across your post.
See example here to do the coloring - https://answers.splunk.com/answers/820403/how-to-change-font-color-based-on-a-condition-for.html.
Then use fields option in simple xml to show only the columns you want. Have fun!

niketn
Legend

@vn86893 refer to one of my answers below. With the suggestion from @kamlesh_vaghela you would be able to get the desired output as expected, however, it requires JS and CSS. If your constraint is to avoid static files like JS and CSS, you can try the other option as proposed in the answer. However, you would see status and host field value also in the table.

https://answers.splunk.com/answers/686288/how-do-you-highlight-a-table-cell-based-on-a-field.html (refer to the first example which does not use JS and applies color via colorPalette using Expressions purely through Simple XML, available in Splunk 6.5 and above ).

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

DavidHourani
Super Champion

Hi @vn86893,

You don't need CSS to achieve this. You can do it using this guide from the documentation:

https://docs.splunk.com/Documentation/Splunk/7.3.1/Viz/TableFormatsXML#Table_format_source_code_exam...

It's quite easy, let me know if you manage to do it or if you need more help.

Cheers,
David

0 Karma

vn86893
Explorer

Thanks For your response David. In the above example looks like you are manually color coding item ID and Category ID. and sorting count based on value. My requirement is a bit different. I need to color Category ID based on count. Lets say the count is between 100 and 150 let the category ID color be red etc..

0 Karma

DavidHourani
Super Champion

Hi @vn86893,

You're welcome. The threshold configuration is also in that same document, around the beginning, here :
https://docs.splunk.com/Documentation/Splunk/7.3.1/Viz/TableFormatsXML#Color_scale_types_and_options

Just collapse the threshold and you'll get this config:

<format type="color" field="purchase_count">
    <scale type="threshold">0,30,70,100</scale>
</format>

You can then combine that with color palette to give the colors based on the threshold.

Is that what you're looking for ?

0 Karma

jacobpevans
Motivator

Correct me if I'm wrong, but your sample would only allow @vn86893 to color the status column. I don't think you can color the host (or any other column) based on the status value without JS.

The Splunk Dashboard Examples app (https://splunkbase.splunk.com/app/1603/) has an easy copy and paste JavaScript dashboard that accomplishes this (they color the whole row based on a single cell's value, but it's similar enough).

Cheers,
Jacob

If you feel this response answered your question, please do not forget to mark it as such. If it did not, but you do have the answer, feel free to answer your own post and accept that as the answer.
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

vn86893
Explorer

Is there a way we can achieve this without using any Js or CSS ??

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...