<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to dynamically fill in a dropdown? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-dynamically-fill-in-a-dropdown/m-p/389381#M25517</link>
    <description>&lt;P&gt;@wti you can try adding the following to your existing search instead of &lt;CODE&gt;| stats count by plugcount&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;yourCurrentSearch  to fetch plugcount&amp;gt;
 | stats max(plugcount) as plugcount
 | eval "plugcount"='plugcount'+1
 | eval "plugcount"=mvrange(1,'plugcount')
 | stats count by plugcount
 | fields - count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: As per &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Viz/Savedsearches#Best_practices"&gt;Post Processing Best Practices&lt;/A&gt;, you should not pass on raw data through post-processing (which may actually silently drop data as well and also cause high memory consumption in your dashboard). If you really need to reuse the data from a search result across the dashboard, you should ensure the data is sent through a transforming command via the base search like stats or timechart so that results are reduced to what you are interested in.&lt;/P&gt;

&lt;P&gt;Try the following run anywhere example based on the sample data provided&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw=
    "{
     \"sourcetype\": \"powerdata\",
     \"event\": {
         \"timestamp\": \"2019-05-22T17:14:53+00:00\", 
         \"siteid\": \"OFFICE158RACK\", 
         \"assettag\": \"DEVICECPM16\", 
         \"branchcount\": \"4\", 
         \"plugcount\": \"8\"
         }
 }" 
| append 
    [| makeresults 
    | eval _raw=
        "{
        \"sourcetype\": \"powerdata\",
        \"event\": {
        \"timestamp\": \"2019-05-22T17:14:55+00:00\", 
        \"siteid\": \"OFFICE158RACK\", 
        \"assettag\": \"DEVICEVMR8\", 
        \"branchcount\": \"2\", 
        \"plugcount\": \"4\"
        }
        }"]
 | spath
 | stats max(event.plugcount) as event.plugcount
 | eval "event.plugcount"='event.plugcount'+1
 | eval "event.plugcount"=mvrange(1,'event.plugcount')
 | stats count by event.plugcount
 | fields - count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 29 May 2019 03:46:26 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2019-05-29T03:46:26Z</dc:date>
    <item>
      <title>How to dynamically fill in a dropdown?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-dynamically-fill-in-a-dropdown/m-p/389378#M25514</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;

&lt;P&gt;We have some custom JSON data getting in to Splunk. We are also creating some dashboards with this data.&lt;BR /&gt;
Everything is working great, except for drop down boxes. &lt;/P&gt;

&lt;P&gt;In our data, (below), we have JSON coming from two different devices, one has a  &lt;CODE&gt;plugcount&lt;/CODE&gt; of 8 and another has a  &lt;CODE&gt;plugcount&lt;/CODE&gt; of 4.&lt;BR /&gt;&lt;BR /&gt;
 In our dropdown we are reading the JSON values, the listbox shows values of 8, and 4 as the only selections (as expected). &lt;/P&gt;

&lt;P&gt;What I would like to do is show all selections for the numbers in between, from 1 to the maximum read also (i.e. 1,2,3,4,5,6,7,8). &lt;BR /&gt;
Could anyone point me in the right direction ?&lt;BR /&gt;
Thanks.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;JSON CODE sent to Splunk
{
    "sourcetype": "powerdata",
    "event": {
        "timestamp": "2019-05-22T17:14:53+00:00", 
        "siteid": "OFFICE158RACK", 
        "assettag": "DEVICECPM16", 
        "branchcount": "4", 
        "plugcount": "8", 
    }
}

{
    "sourcetype": "powerdata",
    "event": {
        "timestamp": "2019-05-22T17:14:55+00:00", 
        "siteid": "OFFICE158RACK", 
        "assettag": "DEVICEVMR8", 
        "branchcount": "2", 
        "plugcount": "4", 
    }
}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 May 2019 17:45:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-dynamically-fill-in-a-dropdown/m-p/389378#M25514</guid>
      <dc:creator>wti</dc:creator>
      <dc:date>2019-05-22T17:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically fill in a dropdown?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-dynamically-fill-in-a-dropdown/m-p/389379#M25515</link>
      <description>&lt;P&gt;What's your current query that populates the dropdown?&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2019 18:41:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-dynamically-fill-in-a-dropdown/m-p/389379#M25515</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2019-05-22T18:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically fill in a dropdown?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-dynamically-fill-in-a-dropdown/m-p/389380#M25516</link>
      <description>&lt;PRE&gt;&lt;CODE&gt; &amp;lt;query&amp;gt;index="main" | table sourcetype, siteid, assettag,  branchcount, plugcount,  timestamp  |  eval timestamp_epoc = strptime (timestamp, "%Y-%m-%d") | eval release_year = strftime(timestamp_epoc, "%Y") | eval release_month = strftime(timestamp_epoc, "%m") | fillnull value="No Defined" release_year,  plugcount | search sourcetype=powerdata  &amp;lt;/query&amp;gt;

 &amp;lt;input type="dropdown" token="branchcount" searchWhenChanged="true"&amp;gt;
   &amp;lt;label&amp;gt;branchcount&amp;lt;/label&amp;gt;
   &amp;lt;search base="base_search"&amp;gt;
     &amp;lt;query&amp;gt;| stats count by branchcount&amp;lt;/query&amp;gt;
   &amp;lt;/search&amp;gt;
   &amp;lt;choice value="*"&amp;gt;All&amp;lt;/choice&amp;gt;
   &amp;lt;default&amp;gt;*&amp;lt;/default&amp;gt;
   &amp;lt;initialValue&amp;gt;*&amp;lt;/initialValue&amp;gt;
   &amp;lt;fieldForLabel&amp;gt;branchcount&amp;lt;/fieldForLabel&amp;gt;
   &amp;lt;fieldForValue&amp;gt;branchcount&amp;lt;/fieldForValue&amp;gt;
 &amp;lt;/input&amp;gt;   
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 May 2019 23:04:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-dynamically-fill-in-a-dropdown/m-p/389380#M25516</guid>
      <dc:creator>wti</dc:creator>
      <dc:date>2019-05-28T23:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically fill in a dropdown?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-dynamically-fill-in-a-dropdown/m-p/389381#M25517</link>
      <description>&lt;P&gt;@wti you can try adding the following to your existing search instead of &lt;CODE&gt;| stats count by plugcount&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;yourCurrentSearch  to fetch plugcount&amp;gt;
 | stats max(plugcount) as plugcount
 | eval "plugcount"='plugcount'+1
 | eval "plugcount"=mvrange(1,'plugcount')
 | stats count by plugcount
 | fields - count
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;PS: As per &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/Viz/Savedsearches#Best_practices"&gt;Post Processing Best Practices&lt;/A&gt;, you should not pass on raw data through post-processing (which may actually silently drop data as well and also cause high memory consumption in your dashboard). If you really need to reuse the data from a search result across the dashboard, you should ensure the data is sent through a transforming command via the base search like stats or timechart so that results are reduced to what you are interested in.&lt;/P&gt;

&lt;P&gt;Try the following run anywhere example based on the sample data provided&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw=
    "{
     \"sourcetype\": \"powerdata\",
     \"event\": {
         \"timestamp\": \"2019-05-22T17:14:53+00:00\", 
         \"siteid\": \"OFFICE158RACK\", 
         \"assettag\": \"DEVICECPM16\", 
         \"branchcount\": \"4\", 
         \"plugcount\": \"8\"
         }
 }" 
| append 
    [| makeresults 
    | eval _raw=
        "{
        \"sourcetype\": \"powerdata\",
        \"event\": {
        \"timestamp\": \"2019-05-22T17:14:55+00:00\", 
        \"siteid\": \"OFFICE158RACK\", 
        \"assettag\": \"DEVICEVMR8\", 
        \"branchcount\": \"2\", 
        \"plugcount\": \"4\"
        }
        }"]
 | spath
 | stats max(event.plugcount) as event.plugcount
 | eval "event.plugcount"='event.plugcount'+1
 | eval "event.plugcount"=mvrange(1,'event.plugcount')
 | stats count by event.plugcount
 | fields - count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 May 2019 03:46:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-dynamically-fill-in-a-dropdown/m-p/389381#M25517</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2019-05-29T03:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to dynamically fill in a dropdown?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-dynamically-fill-in-a-dropdown/m-p/389382#M25518</link>
      <description>&lt;P&gt;Hi @wti  ,&lt;/P&gt;

&lt;P&gt;Did you have a chance to check out @niketnilay  's answer? If it worked, please resolve this post by approving it! If your problem is still not solved, keep us updated so that someone else can help you. &lt;/P&gt;

&lt;P&gt;Thanks for posting!&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2019 18:01:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-dynamically-fill-in-a-dropdown/m-p/389382#M25518</guid>
      <dc:creator>evania</dc:creator>
      <dc:date>2019-06-06T18:01:20Z</dc:date>
    </item>
  </channel>
</rss>

