<?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 How to populate a dropdown from records inside a single JSON event? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-populate-a-dropdown-from-records-inside-a-single-JSON/m-p/326681#M60709</link>
    <description>&lt;P&gt;I have a single json event that contains a list of accounts with a Business Unit Tag. I want to create a dropdown that contains a list of Business Units so the user can see only the accounts in their Business Unit. the single record looks like this in Json format&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{   [-] 
       accounts: [  [-] 
         {  [-]
             BU: BU1        
         Id: Acct1      
         Name: Name1
             } 
            { [-]
             BU: BU1        
         Id: Acct2      
         Name: Name2
             } 
             {  [-]
             BU: BU2        
         Id: Acct3      
         Name: Name3
             }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can get list of unique Business Unit names using this query &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=x | spath output=BUnit path=accounts{}.BU | stats values(BUnit)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But when I try and use the search to populate the dropdown I get a single option that is a comma seperated list i.e. "BU1,BU2"&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   &amp;lt;input type="dropdown" token="BUName"&amp;gt;
  &amp;lt;label&amp;gt;Business Unit&amp;lt;/label&amp;gt;
  &amp;lt;fieldForLabel&amp;gt;BUnit&amp;lt;/fieldForLabel&amp;gt;
  &amp;lt;fieldForValue&amp;gt;BUnit&amp;lt;/fieldForValue&amp;gt;
  &amp;lt;search&amp;gt;
    &amp;lt;query&amp;gt;index=aws sourcetype="acctlistinfo"| spath output=BUnit path=accounts{}.BU | stats values(BUnit) | stats list(values(BUnit)) as BUnit&amp;lt;/query&amp;gt;
    &amp;lt;earliest&amp;gt;-4h@m&amp;lt;/earliest&amp;gt;
    &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
  &amp;lt;/search&amp;gt;
&amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 01 Mar 2018 18:10:33 GMT</pubDate>
    <dc:creator>a238574</dc:creator>
    <dc:date>2018-03-01T18:10:33Z</dc:date>
    <item>
      <title>How to populate a dropdown from records inside a single JSON event?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-populate-a-dropdown-from-records-inside-a-single-JSON/m-p/326681#M60709</link>
      <description>&lt;P&gt;I have a single json event that contains a list of accounts with a Business Unit Tag. I want to create a dropdown that contains a list of Business Units so the user can see only the accounts in their Business Unit. the single record looks like this in Json format&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{   [-] 
       accounts: [  [-] 
         {  [-]
             BU: BU1        
         Id: Acct1      
         Name: Name1
             } 
            { [-]
             BU: BU1        
         Id: Acct2      
         Name: Name2
             } 
             {  [-]
             BU: BU2        
         Id: Acct3      
         Name: Name3
             }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can get list of unique Business Unit names using this query &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=x | spath output=BUnit path=accounts{}.BU | stats values(BUnit)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But when I try and use the search to populate the dropdown I get a single option that is a comma seperated list i.e. "BU1,BU2"&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   &amp;lt;input type="dropdown" token="BUName"&amp;gt;
  &amp;lt;label&amp;gt;Business Unit&amp;lt;/label&amp;gt;
  &amp;lt;fieldForLabel&amp;gt;BUnit&amp;lt;/fieldForLabel&amp;gt;
  &amp;lt;fieldForValue&amp;gt;BUnit&amp;lt;/fieldForValue&amp;gt;
  &amp;lt;search&amp;gt;
    &amp;lt;query&amp;gt;index=aws sourcetype="acctlistinfo"| spath output=BUnit path=accounts{}.BU | stats values(BUnit) | stats list(values(BUnit)) as BUnit&amp;lt;/query&amp;gt;
    &amp;lt;earliest&amp;gt;-4h@m&amp;lt;/earliest&amp;gt;
    &amp;lt;latest&amp;gt;now&amp;lt;/latest&amp;gt;
  &amp;lt;/search&amp;gt;
&amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Mar 2018 18:10:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-populate-a-dropdown-from-records-inside-a-single-JSON/m-p/326681#M60709</guid>
      <dc:creator>a238574</dc:creator>
      <dc:date>2018-03-01T18:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a dropdown from records inside a single JSON event?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-populate-a-dropdown-from-records-inside-a-single-JSON/m-p/326682#M60710</link>
      <description>&lt;P&gt;Your current stats command generates a single row with a multivalued field for BU, the everything in dropdown comes in single option. Try something for your dropdown search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=x | spath output=BUnit path=accounts{}.BU | stats count by BUnit | table BUnit
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Mar 2018 20:22:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-populate-a-dropdown-from-records-inside-a-single-JSON/m-p/326682#M60710</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2018-03-01T20:22:25Z</dc:date>
    </item>
  </channel>
</rss>

