Dashboards & Visualizations

How to unset token if I choose other values from dropdown

spisiakmi
Contributor

Hi,

I have dropdown, where are 30 values. This count can be dynamically changed depends on the search. I want to show some panels, rows, objects in the dashboard ony by choosing 1 value from the dropdown. Otherwise I want to hide these objects. I can do it. I know, if I write hard in xml set and unset condition for all of the values from the dropdown. But, ist there any possibility to do it dynamicaly? E.G. with some OTHERWISE condition for unset the token?
I also tried this method. Everytime at change in the dropdown, unset at first the token.

      <change>
         <condition>
          <unset token="show_token"></unset>
        </condition>
       <condition label="show">
          <set token="show_token">true</set>
        </condition>
      </change>

but it didn't work. By default should be the token show_token set to true. Can you help me, please?

1 Solution

vnravikumar
Champion

Hi

Check this

<form>
  <label>dropdown</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="number">
      <label>field1</label>
      <default>3</default>
      <fieldForLabel>count</fieldForLabel>
      <fieldForValue>count</fieldForValue>
      <search>
        <query>| makeresults count=10 | streamstats count</query>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </search>
      <change>
        <condition match="'value'==&quot;3&quot;">
          <set token="show">true</set>
        </condition>
        <condition>
          <unset token="show"></unset>
        </condition>
      </change>
    </input>
  </fieldset>
  <row depends="$show$">
    <panel>
      <table>
        <search>
          <query>index="_internal" |stats count by sourcetype</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
</form>

View solution in original post

vnravikumar
Champion

Hi

Check this

<form>
  <label>dropdown</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="number">
      <label>field1</label>
      <default>3</default>
      <fieldForLabel>count</fieldForLabel>
      <fieldForValue>count</fieldForValue>
      <search>
        <query>| makeresults count=10 | streamstats count</query>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </search>
      <change>
        <condition match="'value'==&quot;3&quot;">
          <set token="show">true</set>
        </condition>
        <condition>
          <unset token="show"></unset>
        </condition>
      </change>
    </input>
  </fieldset>
  <row depends="$show$">
    <panel>
      <table>
        <search>
          <query>index="_internal" |stats count by sourcetype</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
</form>

spisiakmi
Contributor

Hi vnravikumar,

unbelievable. Really many thanks for such perfect solution. And it is so simple.

0 Karma

vnravikumar
Champion

Welcome 🙂

0 Karma

vnravikumar
Champion

Can you explain your requirement with example?

0 Karma

spisiakmi
Contributor

Hi vnravikumar,

this is the set of all values of the dropdown:
1;2;3;4;5;6;7;8;9;10.
The default value of the dropdown ist 3.
Many objects of the dashboard should be visible, if the value 3 has been choosen. Otherwise should be hidden.
So if I choose 1OR 2 OR 4 OR 5 OR 6 OR 7 OR 8 OR 9 OR 10 from the dropdown, the objects should be invisible.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...