<?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: Color the Table row Cell based on Other Row Cell value in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Color-the-Table-row-Cell-based-on-Other-Row-Cell-value/m-p/385731#M25271</link>
    <description>&lt;P&gt;@askkawalkar&lt;/P&gt;

&lt;P&gt;You can use &lt;CODE&gt;streamstats&lt;/CODE&gt; command to access previous record. So you have made change in search only.&lt;BR /&gt;
Check below search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=10 | eval number=1 | accum number | sort - number | streamstats window=2 first(number) as number_next
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 04 Jan 2019 11:56:58 GMT</pubDate>
    <dc:creator>kamlesh_vaghela</dc:creator>
    <dc:date>2019-01-04T11:56:58Z</dc:date>
    <item>
      <title>Color the Table row Cell based on Other Row Cell value</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Color-the-Table-row-Cell-based-on-Other-Row-Cell-value/m-p/385728#M25268</link>
      <description>&lt;P&gt;Hi All,&lt;BR /&gt;
I would like to achieve attached kind of color coding in splunk table.&lt;BR /&gt;
Requirement : &lt;BR /&gt;&lt;/P&gt;

&lt;P&gt;In a particular column field&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;IF Row 1="" and Row 2="" and Row 3="" then
        Put background color of all 3 row cells to white.
ELSE IF Row 1!="" and Row 2="" and Row 3="" then           // Row 1 cell contains value
        Put background color of all 3 row cells to Yellow.
ELSE IF Row 1!="" and Row 2!="" and Row 3!="" then          // All cell contains value 
        Put Row 1 and Row 2 background color to green and Row 3 cell color to Blue
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please refer attached image for better understanding of requirement. &lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/6329i0D747E3223E8AB07/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2019 05:29:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Color-the-Table-row-Cell-based-on-Other-Row-Cell-value/m-p/385728#M25268</guid>
      <dc:creator>askkawalkar</dc:creator>
      <dc:date>2019-01-04T05:29:25Z</dc:date>
    </item>
    <item>
      <title>Re: Color the Table row Cell based on Other Row Cell value</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Color-the-Table-row-Cell-based-on-Other-Row-Cell-value/m-p/385729#M25269</link>
      <description>&lt;P&gt;@askkawalkar &lt;/P&gt;

&lt;P&gt;You can achieve this using JS and CSS. Can you please check below answer for same?&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/661894/how-to-color-cell-contents-with-css-and-js.html"&gt;https://answers.splunk.com/answers/661894/how-to-color-cell-contents-with-css-and-js.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2019 07:13:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Color-the-Table-row-Cell-based-on-Other-Row-Cell-value/m-p/385729#M25269</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-01-04T07:13:34Z</dc:date>
    </item>
    <item>
      <title>Re: Color the Table row Cell based on Other Row Cell value</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Color-the-Table-row-Cell-based-on-Other-Row-Cell-value/m-p/385730#M25270</link>
      <description>&lt;P&gt;@kamlesh_vaghela , &lt;BR /&gt;
Thank you for your response - I have gone through this and applied the same, but for this i need to make changes in data which loading it to Splunk, I am trying to avoid that scenario. &lt;/P&gt;

&lt;P&gt;From the JS I can get current cell value using below code - &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;render: function($td, cell) {&lt;BR /&gt;
             var label = cell.value.split("|")[0];&lt;BR /&gt;
             var val = cell.value.split("|")[1];&lt;BR /&gt;
...&lt;BR /&gt;
}&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;My requirement will be fulfilled if I get solution to retrieve the data of next 2 rows and &lt;BR /&gt;
I tried to do some changes in JS, but unable to retrieve data of next 2 row cell. Is there any way to get the next row in the same ?&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2019 07:22:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Color-the-Table-row-Cell-based-on-Other-Row-Cell-value/m-p/385730#M25270</guid>
      <dc:creator>askkawalkar</dc:creator>
      <dc:date>2019-01-04T07:22:30Z</dc:date>
    </item>
    <item>
      <title>Re: Color the Table row Cell based on Other Row Cell value</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Color-the-Table-row-Cell-based-on-Other-Row-Cell-value/m-p/385731#M25271</link>
      <description>&lt;P&gt;@askkawalkar&lt;/P&gt;

&lt;P&gt;You can use &lt;CODE&gt;streamstats&lt;/CODE&gt; command to access previous record. So you have made change in search only.&lt;BR /&gt;
Check below search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults count=10 | eval number=1 | accum number | sort - number | streamstats window=2 first(number) as number_next
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 04 Jan 2019 11:56:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Color-the-Table-row-Cell-based-on-Other-Row-Cell-value/m-p/385731#M25271</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-01-04T11:56:58Z</dc:date>
    </item>
    <item>
      <title>Re: Color the Table row Cell based on Other Row Cell value</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Color-the-Table-row-Cell-based-on-Other-Row-Cell-value/m-p/385732#M25272</link>
      <description>&lt;P&gt;@askkawalkar your Table Cell Color requirement seems complex as it has dependency with other rows and columns both at the same time. If you have grasped how @kamlesh_vaghela 's Table Cell Coloring JS works here is how you can modify your query for things to work:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Step 1&lt;/STRONG&gt;: Following Creates Dummy Data as per your question. You should replace Step 1 code with your existing search. PS: You should also let us know your current query as an additional &lt;CODE&gt;transpose (which is expensive command)&lt;/CODE&gt; in &lt;CODE&gt;Step 3&lt;/CODE&gt; can be avoided.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval data="row1,randomevalue1,randomvalue2, ,randomvalue4;row2,contains, , ,contains;row3,pqr, , ,contains;row4, ,randomvalue3,randomvalue5,randomvalue6;row5, ,contains,contains, ;row6, ,contains,pqr, ;" 
| makemv data delim=";" 
| mvexpand data 
| makemv data delim="," 
| eval Header=mvindex(data,0),field1=mvindex(data,1),field2=mvindex(data,2),field3=mvindex(data,3),field4=mvindex(data,4) 
| foreach field* 
    [| eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=trim(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)] 
| table Header field* 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Step 2&lt;/STRONG&gt;: Following section creates groups of three rows as 1, 2, 3. Also gives each group an id as minimum event number of that group (which is calculated using &lt;CODE&gt;streamstats&lt;/CODE&gt; and followed by &lt;CODE&gt;filldown&lt;/CODE&gt;)    &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| streamstats count as event_no 
| sort 0 event_no 
| eval group_row_no=if(event_no%3=0,3,event_no%3) 
| eval group_no=case(group_row_no=1,event_no) 
| filldown group_no 
| eval Header="group".group_no."_group_row_no".group_row_no 
| table Header field* 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Step 3&lt;/STRONG&gt;: &lt;CODE&gt;Transpose&lt;/CODE&gt; is used to convert Row to Column as &lt;CODE&gt;foreach&lt;/CODE&gt; template needs to be applied for Events in each group of Rows.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| transpose 0 header_field="Header" column_name="Header" 
| foreach "group*_group_row_no1" 
    [| eval "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"=case(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=="" AND group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no2=="" AND 'group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no3'=="" ,&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;."|White",
        &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;!="" AND group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no2=="" AND 'group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no3'=="" ,&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;."|Yellow",
        &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;!="" AND group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no2!="" AND 'group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no3'!="" ,&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;."|Green",
        true(),&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)] 
| foreach "group*_group_row_no2" 
    [| eval "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"=case(match(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no1,"|White"),&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;."|White",
        match(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no1,"|Yellow"),&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;."|Yellow",
        match(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no1,"|Green"),&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;."|Green",
        true(),&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)]
| foreach "group*_group_row_no3" 
    [| eval "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"=case(match(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no1,"|White"),&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;."|White",
        match(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no1,"|Yellow"),&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;."|Yellow",
        match(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no1,"|Green"),&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;."|Blue",
        true(),&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Step 4&lt;/STRONG&gt;: Final &lt;CODE&gt;transpose&lt;/CODE&gt; is applied to revert back the table to a format which can be consumed by the JS for Table Cell Coloring. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| transpose 0 header_field="Header" column_name="Header"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: I have applied the logic for Color dependency based on your explanation. &lt;BR /&gt;
1) Color for &lt;CODE&gt;Row 1&lt;/CODE&gt; needs to be decided based on which colors of Row 2 and Row 3 can be derived.&lt;BR /&gt;
2) Table can have N rows but in multiple of 3 as three rows are mutually dependent for coloring logic.&lt;BR /&gt;
3) &lt;CODE&gt;sort 0 event_no&lt;/CODE&gt; is enforcing sorting of events. It may not be required if you have similar sort present already in your current search.&lt;BR /&gt;
4) As stated earlier depending on your current search an additional transpose in Step 3 can be avoided if foreach template can be applied directed on sorted raw events.&lt;/P&gt;

&lt;P&gt;For details on the commands used in this example do refer &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/WhatsInThisManual"&gt;Splunk Docs&lt;/A&gt;.&lt;BR /&gt;
Please try out and confirm!&lt;/P&gt;</description>
      <pubDate>Sat, 05 Jan 2019 08:47:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Color-the-Table-row-Cell-based-on-Other-Row-Cell-value/m-p/385732#M25272</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-01-05T08:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: Color the Table row Cell based on Other Row Cell value</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Color-the-Table-row-Cell-based-on-Other-Row-Cell-value/m-p/385733#M25273</link>
      <description>&lt;P&gt;@niketnilay , Thank you for your response.. I will try and will let you know, is it works or not.. &lt;/P&gt;

&lt;P&gt;Thank You,&lt;BR /&gt;
Ankush&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 06:19:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Color-the-Table-row-Cell-based-on-Other-Row-Cell-value/m-p/385733#M25273</guid>
      <dc:creator>askkawalkar</dc:creator>
      <dc:date>2019-01-07T06:19:00Z</dc:date>
    </item>
    <item>
      <title>Re: Color the Table row Cell based on Other Row Cell value</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Color-the-Table-row-Cell-based-on-Other-Row-Cell-value/m-p/385734#M25274</link>
      <description>&lt;P&gt;Hi @niketnilay , &lt;BR /&gt;
It worked, Thank you for help ! and Thanks for providing logic.&lt;BR /&gt;&lt;BR /&gt;
I have made some small changes in Step 3 query to match the color code. I am posting the Changed code for other people reference below. &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Changes :&lt;/STRONG&gt; &lt;BR /&gt;
1.  To check Null values function used - isnull().&lt;BR /&gt;
2.  Additional condition added.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Step 3 :  With Changes:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|  transpose 0 header_field="Header" column_name="Header"
|  foreach "group*_group_row_no1" 
     [| eval "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"=case(isnull(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) AND isnull(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no2) AND isnull(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no3) ," |White",
         isnotnull(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) AND isnull(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no2) AND isnull(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no3) ,&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;."|Yellow",
         isnotnull(&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;) AND isnotnull(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no2) AND isnotnull(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no3) ,&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;."|Green",
         true(),&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)]
 | foreach "group*_group_row_no2" 
     [| eval "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"=case(isnull(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no2) and match(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no1,"dummy|Yellow")," |Yellow",
         isnull(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no2) and match(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no1,"dummy|White")," |White",
         match(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no1,"dummy|Green"),&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;."|Green",
         match(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no1,"dummy|Yellow"),&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;."|Yellow",
         match("group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no1","|White"),&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;."|White",
         true(),&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)]
 | foreach "group*_group_row_no3" 
     [| eval "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"=case(isnull(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no3) and match(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no1,"dummy|Yellow")," |Yellow",
         isnull(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no3) and match(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no1,"dummy|White")," |White",
         match(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no1,"dummy|Green"),&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;."|Blue",
         match(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no1,"dummy|Yellow"),&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;."|Yellow",
         match(group&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;_group_row_no1,"|White"),&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;."|White",
         true(),&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;)]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks to @kamlesh_vaghela  for CSS and JS. &lt;BR /&gt;
Also Please refer below link for CSS and JS which will be used to color code the cell - &lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/661894/how-to-color-cell-contents-with-css-and-js.html"&gt;https://answers.splunk.com/answers/661894/how-to-color-cell-contents-with-css-and-js.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 10:51:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Color-the-Table-row-Cell-based-on-Other-Row-Cell-value/m-p/385734#M25274</guid>
      <dc:creator>askkawalkar</dc:creator>
      <dc:date>2019-01-07T10:51:28Z</dc:date>
    </item>
    <item>
      <title>Re: Color the Table row Cell based on Other Row Cell value</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Color-the-Table-row-Cell-based-on-Other-Row-Cell-value/m-p/385735#M25275</link>
      <description>&lt;P&gt;@askkawalkar Glad it worked! Thanks for an interesting challenge as this is the first question I noticed on Splunk Answers for &lt;CODE&gt;Row based Table Cell Color logic&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Do Accept one of the answers to mark this question as answered and Up Vote the answers/comments that helped!&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 11:04:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Color-the-Table-row-Cell-based-on-Other-Row-Cell-value/m-p/385735#M25275</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-01-07T11:04:10Z</dc:date>
    </item>
  </channel>
</rss>

