Dashboards & Visualizations

How to hide/show panel when using multiselect with dynamic list?

jason_hotchkiss
Communicator

I have created a multiselect input using a dynamic list:

 

 

 

<input type="multiselect" token="my_id" searchWhenChanged="true">
      <label>My ID</label>
      <fieldForLabel>my_id</fieldForLabel>
      <fieldForValue>my_id</fieldForValue>
      <search>
        <progress>
          <condition match="'job.resultCount'==1">
            <set token="form.my_id">$result.my_id$</set>
            <set token="my_id">$result.my_id$</set>
          </condition>
        </progress>
        <query>| tstats values(my_id) as my_id where index=my_index sourcetype IN (my_sourcetype) 
| mvexpand my_id 
| table my_id 
| dedup my_id</query>
        <earliest>$time.earliest$</earliest>
        <latest>$time.latest$</latest>
      </search>
      <valuePrefix>"</valuePrefix>
      <valueSuffix>"</valueSuffix>
      <delimiter>, </delimiter>
    </input>

 

 

 

 

 


I also have a Pie Chart:

 

 

 

<row>
<panel>
<title>Total Vulnerabilities by My ID</title>
<chart>
<search base="base_search">
<query>| stats count by my_id</query>
</search>
<option name="charting.axisTitleX.visibility">visible</option>
<option name="charting.axisTitleY.visibility">visible</option>
<option name="charting.axisTitleY2.visibility">visible</option>
<option name="charting.axisY.abbreviation">auto</option>
<option name="charting.chart">pie</option>
<option name="charting.chart.nullValueMode">zero</option>
<option name="charting.chart.stackMode">stacked</option>
<option name="charting.drilldown">all</option>
<option name="charting.legend.labelStyle.overflowMode">ellipsisEnd</option>
<option name="charting.legend.placement">right</option>
<option name="link.exportResults.visible">$exportResults$</option>
<option name="link.inspectSearch.visible">$inspectSearch$</option>
<option name="link.openPivot.visible">$openPivot$</option>
<option name="link.openSearch.visible">$openSearch$</option>
<option name="refresh.display">progressbar</option>
<drilldown>
<set token="form.my_id">$click.value$</set>
</drilldown>
</chart>
</panel>

 

 

 


I would like to HIDE the panel (not the row) in the event only value is selected from the multiselect.  I would like to SHOW the panel (not the row) in the event more than one value is selected from the multiselect.

Is this possible?  I have seen this accomplished for static lists, but I am unable to use a static list in this instance.  Thank you.

Labels (2)
0 Karma
1 Solution

maciep
Champion

Since you are delimiting the multi-select input values with a comma when more than one value is selected, then you should be able to use that to determine if you should show the panel.  And that should be doable with the change condition of the input by setting a new token that can be used with the depends attribute of your panel.

Here is a simple example:

<form>
  <label>My Dashboard</label>
  <fieldset submitButton="false">
    <input type="multiselect" token="t_sourcetype" searchWhenChanged="true">
      <label>Choose Sources</label>
      <valuePrefix>"</valuePrefix>
      <valueSuffix>"</valueSuffix>
      <delimiter>,</delimiter>
      <fieldForLabel>sourcetype</fieldForLabel>
      <fieldForValue>sourcetype</fieldForValue>
      <search>
        <query>| tstats count where index=_internal by sourcetype</query>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </search>
      <change>
        <eval token="t_show_panel">if(match($t_sourcetype$,","),1,null())</eval>
      </change>
    </input>
  </fieldset>
  <row>
    <panel depends="$t_show_panel$">
      <table>
        <search>
          <query>| tstats count where index=_internal by source, sourcetype</query>
          <earliest>@d</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
      </table>
    </panel>
  </row>
</form>

  

View solution in original post

0 Karma

maciep
Champion

Since you are delimiting the multi-select input values with a comma when more than one value is selected, then you should be able to use that to determine if you should show the panel.  And that should be doable with the change condition of the input by setting a new token that can be used with the depends attribute of your panel.

Here is a simple example:

<form>
  <label>My Dashboard</label>
  <fieldset submitButton="false">
    <input type="multiselect" token="t_sourcetype" searchWhenChanged="true">
      <label>Choose Sources</label>
      <valuePrefix>"</valuePrefix>
      <valueSuffix>"</valueSuffix>
      <delimiter>,</delimiter>
      <fieldForLabel>sourcetype</fieldForLabel>
      <fieldForValue>sourcetype</fieldForValue>
      <search>
        <query>| tstats count where index=_internal by sourcetype</query>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </search>
      <change>
        <eval token="t_show_panel">if(match($t_sourcetype$,","),1,null())</eval>
      </change>
    </input>
  </fieldset>
  <row>
    <panel depends="$t_show_panel$">
      <table>
        <search>
          <query>| tstats count where index=_internal by source, sourcetype</query>
          <earliest>@d</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
      </table>
    </panel>
  </row>
</form>

  

0 Karma

jason_hotchkiss
Communicator

Very nice!  Thank you for this.  

0 Karma
Get Updates on the Splunk Community!

Splunk AI Assistant for SPL | Key Use Cases to Unlock the Power of SPL

Splunk AI Assistant for SPL | Key Use Cases to Unlock the Power of SPL  The Splunk AI Assistant for SPL ...

Buttercup Games: Further Dashboarding Techniques (Part 5)

This series of blogs assumes you have already completed the Splunk Enterprise Search Tutorial as it uses the ...

Customers Increasingly Choose Splunk for Observability

For the second year in a row, Splunk was recognized as a Leader in the 2024 Gartner® Magic Quadrant™ for ...