Dashboards & Visualizations

Populate dropdown based on previous dropdown value

k_harini
Communicator

I'm able to populate dropdown based on previous dropdown value with passing that token. But when ALL is selected in previous dropdown , i want "ALL" to appear in dependent dropdown without any values. Only when some value is selected, other dropdown should refresh accordingly.

How to achieve that.. ?

Tags (1)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi k_harini,
I don't know how is written your dropdown, but I think that in the first one you have ALL ("") as default value and you pass the choosen value (a single value or "") to the second one.
In the second dashboard, I think that you use the first dropdown choice as a filter in the search (e.g.: mysearch $token$), and you have ALL ("*") as default value.
In this way, if you have ALL in the first dropdown, you have ALL also in the second one, if instead you choose a value in the first dropdawn, you have in the second one the possibility to choose both ALL or a single value.
In other word something like this:

<input type="dropdown" token="My1" searchWhenChanged="true">
  <choice value="*">All</choice>
  <search>
    <query>tag=mytag | dedup SS | table My1 | sort My1 </query>
    <earliest>$Time.earliest$</earliest>
    <latest>$Time.latest$</latest>
  </search>
  <fieldForLabel>My1</fieldForLabel>
  <fieldForValue>My1</fieldForValue>
  <default>*</default>
  <prefix>My1="</prefix>
  <suffix>"</suffix>
</input>
<input type="dropdown" token="My2" searchWhenChanged="true">
  <choice value="*">All</choice>
  <search>
    <query>tag=mytag $My1$| dedup My2 | table My2 | sort My2</query>
    <earliest>$Time.earliest$</earliest>
    <latest>$Time.latest$</latest>
  </search>
  <fieldForLabel>My2</fieldForLabel>
  <fieldForValue>My2</fieldForValue>
  <default>*</default>
  <prefix>My2="</prefix>
  <suffix>"</suffix>
</input>

Bye.
Giuseppe

View solution in original post

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi k_harini,
I don't know how is written your dropdown, but I think that in the first one you have ALL ("") as default value and you pass the choosen value (a single value or "") to the second one.
In the second dashboard, I think that you use the first dropdown choice as a filter in the search (e.g.: mysearch $token$), and you have ALL ("*") as default value.
In this way, if you have ALL in the first dropdown, you have ALL also in the second one, if instead you choose a value in the first dropdawn, you have in the second one the possibility to choose both ALL or a single value.
In other word something like this:

<input type="dropdown" token="My1" searchWhenChanged="true">
  <choice value="*">All</choice>
  <search>
    <query>tag=mytag | dedup SS | table My1 | sort My1 </query>
    <earliest>$Time.earliest$</earliest>
    <latest>$Time.latest$</latest>
  </search>
  <fieldForLabel>My1</fieldForLabel>
  <fieldForValue>My1</fieldForValue>
  <default>*</default>
  <prefix>My1="</prefix>
  <suffix>"</suffix>
</input>
<input type="dropdown" token="My2" searchWhenChanged="true">
  <choice value="*">All</choice>
  <search>
    <query>tag=mytag $My1$| dedup My2 | table My2 | sort My2</query>
    <earliest>$Time.earliest$</earliest>
    <latest>$Time.latest$</latest>
  </search>
  <fieldForLabel>My2</fieldForLabel>
  <fieldForValue>My2</fieldForValue>
  <default>*</default>
  <prefix>My2="</prefix>
  <suffix>"</suffix>
</input>

Bye.
Giuseppe

0 Karma

k_harini
Communicator

Thank you so much for your response and the code. I tried this.. Even then All values are getting populated wen i select 'All' in first drop down.. I just want to display 'All' and user should not have the ability to select other values from second drop down.

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!

From Data to Insight: Announcing the Winners of the Splunk Dashboard Contest

Hi Splunkers, First off, thank you to everyone who participated in our very first From Data to Insight: The ...

Splunk Developers: Construct Your Future at the .conf26 Builder Bar

Calling all Splunk architects, platform admins, and app developers: the site is open, and the blueprints are ...

Quick connection discovery mode for forwarders

When a Splunk forwarder loses connectivity to its indexers, it does not always reconnect immediately. In many ...