<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to set color to field in table that greater than field value in other column? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-color-to-field-in-table-that-greater-than-field-value/m-p/632479#M51835</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/254213"&gt;@AntonB&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can achieve this by using JS extension.&amp;nbsp; Try the below code.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;dashboard version="1.1" script="a.js"&amp;gt;
  &amp;lt;label&amp;gt;version column&amp;lt;/label&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table id="tknTable"&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults 
| eval title="XYZ", version="3.0.0", updatedversion="3.0.1" 
| eval flag= if(updatedversion &amp;amp;gt; version, "1","0")
| eval updatedversion=updatedversion+"|"+flag
| table title version updatedversion&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;require([
  'underscore',
  'jquery',
  'splunkjs/mvc',
  'splunkjs/mvc/tableview',
  'splunkjs/mvc/simplexml/ready!'
], function(_, $, mvc, TableView) {
        
  var CustomRangeRenderer = TableView.BaseCellRenderer.extend({
          canRender: function(cell) {
                  //console.log("Enable this custom cell renderer for field");
                  return _(["updatedversion"]).contains(cell.field);
          },
          render: function($td, cell) {
            var strCellValue = cell.value.split("|")[0];
            var strFlag = cell.value.split("|")[1];

                  if (cell.field === "updatedversion" &amp;amp;&amp;amp; strFlag=="1") {
                    var strHtmlInput="&amp;lt;div style='background-color:DodgerBlue'&amp;gt;"+strCellValue+"&amp;lt;/div&amp;gt;";
                  } else {
                    var strHtmlInput="&amp;lt;div&amp;gt;"+strCellValue+"&amp;lt;/div&amp;gt;";
                  }
                 $td.append(strHtmlInput);
          }
  });

  mvc.Components.get('tknTable').getVisualization(function(tableView) {
          // Add custom cell renderer, the table will re-render automatically.
          tableView.table.addCellRenderer(new CustomRangeRenderer());
          tableView.table.render();
  });
});
&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-02-28 at 10.22.22 AM.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24077iAE07DD9DE80C94ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2023-02-28 at 10.22.22 AM.png" alt="Screenshot 2023-02-28 at 10.22.22 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: Change style as per your requirement.&lt;/P&gt;&lt;P&gt;I hope this will help you.&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;KV&lt;BR /&gt;If any of my replies help you to solve the problem Or gain knowledge, an upvote would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 28 Feb 2023 04:52:44 GMT</pubDate>
    <dc:creator>kamlesh_vaghela</dc:creator>
    <dc:date>2023-02-28T04:52:44Z</dc:date>
    <item>
      <title>How to set color to field in table that greater than field value in other column?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-color-to-field-in-table-that-greater-than-field-value/m-p/632190#M51824</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I need to color the value in update.version column when this is greater than value in version column&lt;BR /&gt;how can I do this?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AntonB_0-1677242187152.png" style="width: 782px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24036i459890E614AF1BE6/image-dimensions/782x43?v=v2" width="782" height="43" role="button" title="AntonB_0-1677242187152.png" alt="AntonB_0-1677242187152.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 16:27:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-color-to-field-in-table-that-greater-than-field-value/m-p/632190#M51824</guid>
      <dc:creator>AntonB</dc:creator>
      <dc:date>2023-02-24T16:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to set color to field in table that greater than field value in other column?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-color-to-field-in-table-that-greater-than-field-value/m-p/632479#M51835</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/254213"&gt;@AntonB&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can achieve this by using JS extension.&amp;nbsp; Try the below code.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;dashboard version="1.1" script="a.js"&amp;gt;
  &amp;lt;label&amp;gt;version column&amp;lt;/label&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;table id="tknTable"&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;| makeresults 
| eval title="XYZ", version="3.0.0", updatedversion="3.0.1" 
| eval flag= if(updatedversion &amp;amp;gt; version, "1","0")
| eval updatedversion=updatedversion+"|"+flag
| table title version updatedversion&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;-24h@h&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;option name="drilldown"&amp;gt;none&amp;lt;/option&amp;gt;
        &amp;lt;option name="refresh.display"&amp;gt;progressbar&amp;lt;/option&amp;gt;
      &amp;lt;/table&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/dashboard&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;require([
  'underscore',
  'jquery',
  'splunkjs/mvc',
  'splunkjs/mvc/tableview',
  'splunkjs/mvc/simplexml/ready!'
], function(_, $, mvc, TableView) {
        
  var CustomRangeRenderer = TableView.BaseCellRenderer.extend({
          canRender: function(cell) {
                  //console.log("Enable this custom cell renderer for field");
                  return _(["updatedversion"]).contains(cell.field);
          },
          render: function($td, cell) {
            var strCellValue = cell.value.split("|")[0];
            var strFlag = cell.value.split("|")[1];

                  if (cell.field === "updatedversion" &amp;amp;&amp;amp; strFlag=="1") {
                    var strHtmlInput="&amp;lt;div style='background-color:DodgerBlue'&amp;gt;"+strCellValue+"&amp;lt;/div&amp;gt;";
                  } else {
                    var strHtmlInput="&amp;lt;div&amp;gt;"+strCellValue+"&amp;lt;/div&amp;gt;";
                  }
                 $td.append(strHtmlInput);
          }
  });

  mvc.Components.get('tknTable').getVisualization(function(tableView) {
          // Add custom cell renderer, the table will re-render automatically.
          tableView.table.addCellRenderer(new CustomRangeRenderer());
          tableView.table.render();
  });
});
&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-02-28 at 10.22.22 AM.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24077iAE07DD9DE80C94ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2023-02-28 at 10.22.22 AM.png" alt="Screenshot 2023-02-28 at 10.22.22 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: Change style as per your requirement.&lt;/P&gt;&lt;P&gt;I hope this will help you.&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;KV&lt;BR /&gt;If any of my replies help you to solve the problem Or gain knowledge, an upvote would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 04:52:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-color-to-field-in-table-that-greater-than-field-value/m-p/632479#M51835</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2023-02-28T04:52:44Z</dc:date>
    </item>
  </channel>
</rss>

