Dashboards & Visualizations

How to make multiple panels to disappear/appear when changes to radio button happen?

thisemailwillbe
Explorer

So basically what I'm trying to do it that I want a radio button at the top of the page and depending on one of the four choices of sais radio button, make a whole swath of panels to appear/disappear. I'm having troubles trying to figure out how to use the tokens to achieve this. Thanks in advance for any help! (I should also mention that I'm running 7.2.5)

0 Karma
1 Solution

manjunathmeti
Champion

hi @thisemailwillbeusedfortesting,

Try this:

<form hideSplunkBar="true">
  <label>Choose filters</label>
  <fieldset submitButton="false">
    <input type="radio" token="checkbox">
      <label>Checkbox</label>
      <choice value="checkbox1">Show Panel 1</choice>
      <choice value="checkbox2">Show Panel 2</choice>
      <choice value="checkbox3">Show Panel 3</choice>
      <choice value="checkbox4">Show Panel 4</choice>
      <change>
        <condition value="checkbox1">
          <set token="flag1">true</set>
          <unset token="flag2"></unset>
          <unset token="flag3"></unset>
          <unset token="flag4"></unset>
        </condition>
        <condition value="checkbox2">
          <set token="flag2">true</set>
          <unset token="flag1"></unset>
          <unset token="flag3"></unset>
          <unset token="flag4"></unset>
        </condition>
        <condition value="checkbox3">
          <set token="flag3">true</set>
          <unset token="flag1"></unset>
          <unset token="flag2"></unset>
          <unset token="flag4"></unset>
        </condition>
        <condition value="checkbox4">
          <set token="flag4">true</set>
          <unset token="flag1"></unset>
          <unset token="flag2"></unset>
          <unset token="flag3"></unset>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel depends="$flag1$">
      <title>Panel 1</title>
      <table>
        <title>Count by sourcetype</title>
        <search>
          <query>index=_internal earliest=-5m | stats count by sourcetype</query>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
      </table>
    </panel>
    <panel depends="$flag2$">
      <title>Panel 2</title>
      <table>
        <title>Count by source</title>
        <search>
          <query>index=_internal earliest=-5m | stats count by source</query>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
      </table>
    </panel>
    <panel depends="$flag3$">
      <title>Panel 3</title>
      <table>
        <title>Count by host</title>
        <search>
          <query>index=_internal earliest=-5m | stats count by host</query>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
      </table>
    </panel>
    <panel depends="$flag4$">
      <title>Panel 4</title>
      <table>
        <title>Count by splunk server</title>
        <search>
          <query>index=_internal earliest=-5m | stats count by splunk_server</query>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
</form>

View solution in original post

manjunathmeti
Champion

hi @thisemailwillbeusedfortesting,

Try this:

<form hideSplunkBar="true">
  <label>Choose filters</label>
  <fieldset submitButton="false">
    <input type="radio" token="checkbox">
      <label>Checkbox</label>
      <choice value="checkbox1">Show Panel 1</choice>
      <choice value="checkbox2">Show Panel 2</choice>
      <choice value="checkbox3">Show Panel 3</choice>
      <choice value="checkbox4">Show Panel 4</choice>
      <change>
        <condition value="checkbox1">
          <set token="flag1">true</set>
          <unset token="flag2"></unset>
          <unset token="flag3"></unset>
          <unset token="flag4"></unset>
        </condition>
        <condition value="checkbox2">
          <set token="flag2">true</set>
          <unset token="flag1"></unset>
          <unset token="flag3"></unset>
          <unset token="flag4"></unset>
        </condition>
        <condition value="checkbox3">
          <set token="flag3">true</set>
          <unset token="flag1"></unset>
          <unset token="flag2"></unset>
          <unset token="flag4"></unset>
        </condition>
        <condition value="checkbox4">
          <set token="flag4">true</set>
          <unset token="flag1"></unset>
          <unset token="flag2"></unset>
          <unset token="flag3"></unset>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel depends="$flag1$">
      <title>Panel 1</title>
      <table>
        <title>Count by sourcetype</title>
        <search>
          <query>index=_internal earliest=-5m | stats count by sourcetype</query>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
      </table>
    </panel>
    <panel depends="$flag2$">
      <title>Panel 2</title>
      <table>
        <title>Count by source</title>
        <search>
          <query>index=_internal earliest=-5m | stats count by source</query>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
      </table>
    </panel>
    <panel depends="$flag3$">
      <title>Panel 3</title>
      <table>
        <title>Count by host</title>
        <search>
          <query>index=_internal earliest=-5m | stats count by host</query>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
      </table>
    </panel>
    <panel depends="$flag4$">
      <title>Panel 4</title>
      <table>
        <title>Count by splunk server</title>
        <search>
          <query>index=_internal earliest=-5m | stats count by splunk_server</query>
        </search>
        <option name="count">10</option>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
</form>

thisemailwillbe
Explorer

Thank you! This is exactly what I needed. Cheers!

0 Karma

manjunathmeti
Champion

You're welcome 🙂

0 Karma
Get Updates on the Splunk Community!

CX Day is Coming!

Customer Experience (CX) Day is on October 7th!! We're so excited to bring back another day full of wonderful ...

Strengthen Your Future: A Look Back at Splunk 10 Innovations and .conf25 Highlights!

The Big One: Splunk 10 is Here!  The moment many of you have been waiting for has arrived! We are thrilled to ...

Now Offering the AI Assistant Usage Dashboard in Cloud Monitoring Console

Today, we’re excited to announce the release of a brand new AI assistant usage dashboard in Cloud Monitoring ...