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!

Splunk Edge Processor | Popular Use Cases to Get Started with Edge Processor

Splunk Edge Processor offers more efficient, flexible data transformation – helping you reduce noise, control ...

3 Ways to Make OpenTelemetry Even Better

My role as an Observability Specialist at Splunk provides me with the opportunity to work with customers of ...

What's New in Splunk Cloud Platform 9.2.2406?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.2.2406 with many ...