Dashboards & Visualizations

How to dynamically show/hide a dashboard panel based on drop-down selection?

pdpsplunk100
Path Finder

Hello

I have a dashboard with a drop-down containing 3 choices. If choice 3 is selected, I want to show a panel. If choices 1 or 2 are selected, that panel should be hidden. I do see a few posts related to this, but they are not doing the trick for me. I see I have to use , . Dashboard is Simple XML. Splunk version is 6.4.1.2.

The weird thing is, it worked yesterday and I tested it multiple times. I don't remember changing anything, but it is not working today. I tried the "depends" on the and tags but it's not working.

xxx
xxx

  <input type="dropdown" token="type">
    <label>type</label>
    <choice value="a">A</choice>
    <choice value="b">B</choice>
    <choice value="c">C</choice>
    <default>a</default>
    <change>
      <condition value="a">
        <unset token="a-details"></unset>
        <unset token="b-details"></unset>          
        <set token="c-details"></set>
      </condition>  
      <condition value="b">
        <unset token="a-details"></unset>
        <unset token="c-details"></unset>
        <set token="b-details"></set>
      </condition>
      <condition value="c">
        <unset token="a-details"></unset>
        <unset token="b-details"></unset>          
        <set token="c-details"></set>
      </condition>
    </change>
  </input>


<panel depends="$c-details$">
  <chart>
    <title></title>
    <search>
      <query>xxxx</query>
      <earliest>$time_tok.earliest$</earliest>
      <latest>$time_tok.latest$</latest>
    </search>
  </chart>
</panel>
1 Solution

sundareshr
Legend

You you <set> options, add a value. For example <set token="c-details">true</set>. You don't need to do that for <unset>

View solution in original post

Splunk_321
Path Finder

@pdpsplunk100 @sundareshr @ppablo Is there any update for achieving the same in splunk 9.0.5.1 version?

0 Karma

sundareshr
Legend

You you <set> options, add a value. For example <set token="c-details">true</set>. You don't need to do that for <unset>

pdpsplunk100
Path Finder

Yes that did the trick. Thanks a lot!

0 Karma

sundareshr
Legend

Please accept the answer to close it out.

0 Karma

pdpsplunk100
Path Finder

Thanks for your comments. Ok here is the code I have right now.

<input type="dropdown" token="type">
 <label>type</label>
 <choice value="a">A</choice>
 <choice value="b">B</choice>
 <choice value="c">C</choice>
 <default>a</default>
 <change>
   <condition value="a">
     <unset token="b-details"></unset>
     <unset token="c-details"></unset>          
     <set token="a-details"></set>
   </condition>  
   <condition value="b">
     <unset token="a-details"></unset>
     <unset token="c-details"></unset>
     <set token="b-details"></set>
   </condition>
   <condition value="c">
     <unset token="a-details"></unset>
     <unset token="b-details"></unset>          
     <set token="c-details"></set>
   </condition>
 </change>





 <title></title>
 <search>
   <query>xxxx</query>
   <earliest>$time_tok.earliest$</earliest>
   <latest>$time_tok.latest$</latest>
 </search>
0 Karma

pdpsplunk100
Path Finder
<panel depends="$c-details$">
   <chart>
     <title></title>
     <search>
       <query>xxxx</query>
       <earliest>$time_tok.earliest$</earliest>
       <latest>$time_tok.latest$</latest>
     </search>
   </chart>
 </panel>
0 Karma

pdpsplunk100
Path Finder

Sorry for the multiple comments. The tag did not appear and so had to comment again.

0 Karma

ppablo
Retired

Hi @pdpsplunk100

I think some parts of your explanation didn't render properly, particularly the last sentence. Make sure you highlight any sample code (especially anything with angle brackets like XML) and click the Code Sample button in the text editing tools, or surround the code with backticks so it ends up looking like <this>.

0 Karma
Get Updates on the Splunk Community!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk on November 6 at 11AM PT, and empower your SOC to reach new heights! Duration: ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...