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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...