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!

Index This | Why did the turkey cross the road?

November 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...