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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Persistent Queue at TcpOut — One of Splunk's Most Practical Features

Splunk introduced persistent queueing at the tcpout layer as one of the most practical resilience features in ...

Catalog Is Now Generally Available on Splunk Cloud Platform

A Unified View of Your Data  Security logs, application events, business data, and historical telemetry often ...

Your Path to AgenticOps: AI Experiences for Every Splunk Practitioner

Your Path to AgenticOps: AI Experiences for Every Splunk Practitioner   Watch on demand us for a demo-driven ...