Dashboards & Visualizations

I need to highlight the entire row in a table when one field is greater than another field

SathyaNarayanan
Path Finder

Hi ,

I have a table with few rows. i need to highlight the entire row when my allocated field value in greater than purchased field value in it.

Below is my query.

index=snowprod sourcetype="snow:license_details" | table name dv_license_type start_date end_date purchased allocated display_only

Thanks in advance.

Tags (1)
0 Karma

niketn
Legend

@SathyaNarayanan, refer to this answer by @kamlesh_vaghela where two columns are merged into one and used in Simple XML JS Extension where Table Cell Renderer decides color based on comparison of both values and afterwards drops the second value before displaying the table. While this example is for coloring table cell based on two fields, you can extend the same to color the row.

https://answers.splunk.com/answers/661894/how-to-color-cell-contents-with-css-and-js.html

Please try out and confirm. If it works do up vote the answer for the above question as well 🙂

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

SathyaNarayanan
Path Finder

in the mentioned link, he have written the script to compare the constant value, but my values will be keep on changing, i dont think tat will work for me

0 Karma

niketn
Legend

@SathyaNarayanan that example is for specific use case of the question. You would need to create your own logic based on approach mentioned above i.e. create a concatenated field i.e. eval Allocated=Allocated."|".Purchased in your table search query.

Then in JS get Allocated cell and split the value in JS as varAllocated and varPurchased. Compare varAllocated and varPurchased to decide the Color and finally update the cell value as varAllocated to be displayed in table (this will not display additional Purchased information concatenated in SPL above when final table is rendered).

Please let us know if you need further assistance.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...