Dashboards & Visualizations

Can we limit the number of choices in the multiselect input?

pkphmdw
New Member

Can we limit the number of choices in the multiselect input?
I want to have an input as multiselect built from a search and limit the number of select e.g. to 2.

0 Karma

maciep
Champion

Not sure if there is an actual option for that in simple xml, but maybe something like this?

Doesn't seem to work without enabling search on change, but could be something i'm missing there. It's the change tag that decides whether new items are allowed. Essentially after the user adds a 3rd, we change it back to only the first 2. Could also keep the last and remove the first if you wanted.

<input type="multiselect" token="t_comp" searchWhenChanged="true">
  <label>Component</label>
  <search>
    <query>index=_internal | stats count by component</query>
    <earliest>-60m@m</earliest>
    <latest>now</latest>
  </search>
  <change>
    <eval token="form.t_comp">if(mvcount('form.t_comp')=3, mvindex('form.t_comp',0,1),'form.t_comp')</eval>
  </change>
  <fieldForLabel>component</fieldForLabel>
  <fieldForValue>component</fieldForValue>
  <delimiter> OR </delimiter>
  <prefix>(</prefix>
  <suffix>)</suffix>
  <valuePrefix>component = "</valuePrefix>
  <valueSuffix>"</valueSuffix>
</input>

And of course if you only want to limit to 2, you could also just build 2 dropdowns.

pkphmdw
New Member

awesome. thanks. I adjusted the eval with a different token name to make it work.

0 Karma

maciep
Champion

great, glad to help...don't forget to accept the answer too

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...