Dashboards & Visualizations

multiselect with AND

sarit_s6
Engager

Hello

is it possible to use multiselect input in classic dashboard so the selected objects there will be 
key=value AND key=value1 ? if im using IN its acts like OR

 

Thanks

Labels (1)
0 Karma
1 Solution

VatsalJagani
SplunkTrust
SplunkTrust

Yes you can do that. @sarit_s6 

 

You can make use of 

<delimiter>text A string that will be placed between each selected value. Typically, you specify " OR " or " AND " using upper case – do not specify the quote marks, but specify a space character before and after the text.
<valuePrefix>text String prefixed to the value of the input element. Can be a regular expression.
<valueSuffix>text String appended to the value of the input element. Can be a regular expression.

 

delimiter -> AND

valuePrefix -> key="

valueSuffix -> "

 

This will prepare something like -> key="A" AND key="B" ....

 

I hope this helps!!!!

View solution in original post

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @sarit_s6 ,

yes, you can use the IN operator and comma as separator.

Ciao.

Giuseppe

0 Karma

VatsalJagani
SplunkTrust
SplunkTrust

Yes you can do that. @sarit_s6 

 

You can make use of 

<delimiter>text A string that will be placed between each selected value. Typically, you specify " OR " or " AND " using upper case – do not specify the quote marks, but specify a space character before and after the text.
<valuePrefix>text String prefixed to the value of the input element. Can be a regular expression.
<valueSuffix>text String appended to the value of the input element. Can be a regular expression.

 

delimiter -> AND

valuePrefix -> key="

valueSuffix -> "

 

This will prepare something like -> key="A" AND key="B" ....

 

I hope this helps!!!!

0 Karma

sarit_s6
Engager

thanks

its working

is it also possible to set it like that so when object is selected it will remove the "ALL" automatically ?

0 Karma

VatsalJagani
SplunkTrust
SplunkTrust

@sarit_s6 - That one requires Javascript to be written to remove "All" option.

Reference - https://community.splunk.com/t5/Dashboards-Visualizations/Remove-quot-All-quot-from-Multiselect-Inpu...

 

OR you can opt for complex XML editing suggested in this reference - https://community.splunk.com/t5/Dashboards-Visualizations/Remove-ALL-from-multi-select-input-once-an...

 

I hope this helps!!! Kindly upvote if it does!!!

0 Karma

sarit_s6
Engager

well, im using splunk cloud so JS is not an option and  i've tries the second option but its not working
maybe something in the copy paste became wrong ? 

      <input type="multiselect" token="categories">
        <label>Categories</label>
        <choice value="*">ALL</choice>
        <fieldForLabel>testCategories</fieldForLabel>
        <fieldForValue>testCategories</fieldForValue>
        <search>
          <query>index="stg_observability_s" sourcetype=SplunkQuality earliest=$time.earliest$ latest=$time.latest$
| search AdditionalData.domain="$domain$"  AdditionalData.pipelineName="$pipelineName$" AdditionalData.buildId="$jobid$" AdditionalData.repoUrl="$repo$" 

| stats count by testCategories</query>
          <earliest>$time.earliest$</earliest>
          <latest>$time.latest$</latest>
        </search>
        <default>*</default>
        <initialValue>*</initialValue>
        <delimiter> AND </delimiter>
        <valuePrefix>testCategories="</valuePrefix>
        <valueSuffix>"</valueSuffix>
        <change>
          <eval token="form.categories">case(mvcount('form.categories')=0,"All",mvcount('form.categories')&gt;1 AND mvfind('form.categories',"All")&gt;0,"All",mvcount('form.categories')&gt;1 AND mvfind('form.categories',"All")=0,mvfilter('form.categories'!="All"),1==1,'form.categories')</eval>
          <eval token="categories_choice">if('form.categories'=="All","categories=\"*\"",'categories')</eval>
        </change>
      </input>
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

It is not so much the copy paste, it is the value used for All, this needs to be "All" not "*" (similarly with the initialValue)

<form version="1.1" theme="light">
  <label>All handling</label>
  <search id="base_search">
    <query>| makeresults format=csv data="categories
A
B
C"
| table categories</query>
    <earliest>-24h@h</earliest>
    <latest>now</latest>
    <sampleRatio>1</sampleRatio>
  </search>
  <fieldset submitButton="false">
    <input type="multiselect" token="categories">
      <label>Categories</label>
      <choice value="All">All</choice>
      <default>All</default>
      <initialValue>All</initialValue>
      <fieldForLabel>categories</fieldForLabel>
      <fieldForValue>categories</fieldForValue>
      <search base="base_search">
        <query> |stats count by categories </query>
      </search>
      <valuePrefix>testCategories="</valuePrefix>
      <valueSuffix>"</valueSuffix>
      <delimiter> AND </delimiter>
      <change>
        <eval token="form.categories">case(mvcount('form.categories')=0,"All",mvcount('form.categories')&gt;1 AND mvfind('form.categories',"All")&gt;0,"All",mvcount('form.categories')&gt;1 AND mvfind('form.categories',"All")=0,mvfilter('form.categories'!="All"),1==1,'form.categories')</eval>
        <eval token="categories_choice">if('form.categories'=="All","categories=\"*\"",'categories')</eval>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>
        Categories:  $categories_choice$
      </html>
    </panel>
  </row>
</form>
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...