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!

Exciting News: The AppDynamics Community Joins Splunk!

Hello Splunkers,   I’d like to introduce myself—I’m Ryan, the former AppDynamics Community Manager, and I’m ...

The All New Performance Insights for Splunk

Splunk gives you amazing tools to analyze system data and make business-critical decisions, react to issues, ...

Good Sourcetype Naming

When it comes to getting data in, one of the earliest decisions made is what to use as a sourcetype. Often, ...