Dashboards & Visualizations

How to color a table column based on values selected from radio buttons

anooshac
Communicator

Hi All,

I have a dashboard which has 3 radio buttons both,TypeA and TypeB. Also i have a table. The requirement is that, if i select both or TypeA in radio buttons, columnA and columnB in the table should be highlighted. If i select the TypeB, only columnA should be highlighted. How can i achieve this?

I have tried using color palette expression like below. But no luck. Anyone have solution for this?


<format type="color" field="columnA">
<colorPalette type="list">["#00FFFF"]</colorPalette>
</format>

<format type="color" field="columnB">
<colorPalette type="expression">if(match(Type,"TypeB")," ", "#00FFFF")</colorPalette>
</format>

Labels (1)
0 Karma

danspav
SplunkTrust
SplunkTrust

Hi @anooshac,

You were probably really close to the solution for this - but it looks like using tokens to set the colour on tables only works before the table has loaded. The only workaround out I found was to re-run the search each time you select a new radio button.

Here's a working version for you to build from.

The radio buttons set the type:
Both and Type A => Highlight Columns A and B
Type B => Highlight Column B

The table has a format for ColumnA and ColumnB that looks for the right Type in the token:

<format type="color" field="ColumnB">
<colorPalette type="expression">if(match($field_to_highlight|s$,".*TypeB.*"),"#FF0000", "")</colorPalette>
</format>

To make the dashboard redraw with the right columns highlighted, I added this to the query:

``` $field_to_highlight$ ```

That won't do anything to the search results, but will force the search to be run again.


Here is a working dashboard:

<form version="1.1" theme="dark">
  <label>Answers for anooshac</label>
  <fieldset submitButton="false">
    <input type="radio" token="field_to_highlight" searchWhenChanged="true">
      <label>Option</label>
      <choice value="TypeA__TypeB">Both</choice>
      <choice value="TypeA_TypeB">Type A</choice>
      <choice value="TypeB">Type B</choice>
      <default>TypeATypeB</default>
    </input>
  </fieldset>
  <row>
    <panel>
      <table>
        <title>Content</title>
        <search>
          <query>| gentimes start=-20
| eval type=if(random()%2==0,"Type A","Type B")
| appendcols[|windbag]
| fields starttime, endtime, sample, lang, type
| rename starttime as "ColumnA", endtime as "ColumnB"
| head 20 ``` $field_to_highlight$```</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">none</option>
       <format type="color" field="ColumnA">
          <colorPalette type="expression">if(match($field_to_highlight|s$,".*TypeA.*"),"#FF0000", "")</colorPalette>
      </format>
        <format type="color" field="ColumnB">
          <colorPalette type="expression">if(match($field_to_highlight|s$,".*TypeB.*"),"#FF0000", "")</colorPalette>
        </format>
      </table>
    </panel>
  </row>
</form>

 

Hopefully that's close to what you were after.

Get Updates on the Splunk Community!

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...

Splunk MCP & Agentic AI: Machine Data Without Limits

Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization uses ...