<?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 set current month as default value in drop-down? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-current-month-as-default-value-in-drop-down/m-p/288643#M18266</link>
    <description>&lt;P&gt;Hi, the value for drop-down should come from the Leave Start Date and Leave End Date in our data. I don't think I can declare the month as shown above.&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jan 2018 01:49:35 GMT</pubDate>
    <dc:creator>katrinamara</dc:creator>
    <dc:date>2018-01-11T01:49:35Z</dc:date>
    <item>
      <title>How to set current month as default value in drop-down?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-current-month-as-default-value-in-drop-down/m-p/288641#M18264</link>
      <description>&lt;P&gt;I have two drop-down inputs(from and to) where the user can choose the duration of the data to be displayed. I want to use the current month as default of the 2 inputs. How can I do that?&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/4100iE4F02CEF963B0A5C/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Here is my xml code for my 2 inputs.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   &amp;lt;input id="input1" type="dropdown" token="from_tok" searchWhenChanged="true"&amp;gt;
        &amp;lt;label&amp;gt;From&amp;lt;/label&amp;gt;
        &amp;lt;default&amp;gt;&amp;lt;/default&amp;gt;
        &amp;lt;intialvalue&amp;gt;&amp;lt;/intialvalue&amp;gt;
        &amp;lt;fieldForLabel&amp;gt;c_time_show&amp;lt;/fieldForLabel&amp;gt;
        &amp;lt;fieldForValue&amp;gt;c_time_tok&amp;lt;/fieldForValue&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index="acn_pmo_ooo_tier1_idx" 
| rename "Approver Name" as Approver_Name, "Item Type" as Item_Type, "Leave End Date" as "Leave_End_Date", "Leave Start Date" as "Leave_Start_Date", "Leave Type" as "Leave_Type" ,"Total Working Hours on Leave" as Total_Working_Hours_on_Leave, "Supervisor Name" as Supervisor_Name 
| eval start=strptime(Leave_Start_Date,"%m/%d/%Y"), getend=strptime(Leave_End_Date,"%m/%d/%Y"), end=relative_time(getend, "+1day") 
| eval between= mvrange(start, end, "1d") 
| mvexpand between 
| sort between 
| eval c_time_show=strftime(between,"%B-%Y") , c_time_tok=strftime(between,"%b-01-%y"), default=now(), default=strftime(default,"%B-%Y"), 
    default_tok=now(), default_tok=strftime(default_tok,"%b-01-%y") 
| table c_time_show c_time_tok default default_tok 
| dedup c_time_show c_time_tok default&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;0&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;&amp;lt;/latest&amp;gt;

        &amp;lt;/search&amp;gt;
      &amp;lt;/input&amp;gt;
      &amp;lt;input id="input2" type="dropdown" token="to_tok" searchWhenChanged="true"&amp;gt;
        &amp;lt;label&amp;gt;To&amp;lt;/label&amp;gt;
        &amp;lt;selectFirstChoice&amp;gt;true&amp;lt;/selectFirstChoice&amp;gt;
        &amp;lt;fieldForLabel&amp;gt;c_time_show&amp;lt;/fieldForLabel&amp;gt;
        &amp;lt;fieldForValue&amp;gt;c_time_tok&amp;lt;/fieldForValue&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;index="acn_pmo_ooo_tier1_idx"
|dedup EID,"Resource Name","Leave Start Date","Leave Type"

| eval start_date= strptime('Leave Start Date',"%m/%d/%Y"),
       end_date=relative_time(relative_time(strptime('Leave End Date',"%m/%d/%Y"),"@d"), "+1day"),
       between=mvrange(start_date,end_date,"1d")
| mvexpand between
| eval insert=strftime(between,"%m/%d/%Y"), LSD=strptime(insert,"%m/%d/%Y"), _time=LSD
| convert ctime(between) timeformat="%A" 
| rename "Total Working Hours on Leave" as total_working_hours
| eval NoOfLeaveDays=mvcount(mvfilter(NOT match(between,"(Saturday|Sunday).*"))), hours=round(total_working_hours/NoOfLeaveDays,1)
| eval Leaves_value= case(match(between,"Saturday"),"",match(between,"Sunday"),"", 1=1,hours)

| rename "Training Name" as tn 
| eval ftrain=Leaves_value."#".tn
| eval fv = case(Leaves_value="EH",Leaves_value,Leaves_value="H",Leaves_value,Leaves_value="-",Leaves_value,Leaves_value="",Leaves_value,1=1,ftrain)
| timechart span=1d last(fv) by EID limit=0 
| eval twoway= strptime(strftime(_time,"%d/%m/%y"),"%d/%m/%y")

| eval get_tok="$from_tok$", make=strptime(get_tok,"%b-%d-%y") ,between=strptime(strftime(_time,"%b-%d-%y"),"%b-%d-%y")
| where make &amp;lt;= between

| eval c_time_tok=strftime(_time,"%b-%d-%y"),c_time_show=strftime(_time,"%B-%Y") 
| eventstats last(c_time_tok) as c_time_tok by c_time_show
| table c_time_show c_time_tok  
| sort twoway
| dedup c_time_tok&amp;lt;/query&amp;gt;
          &amp;lt;earliest&amp;gt;0&amp;lt;/earliest&amp;gt;
          &amp;lt;latest&amp;gt;&amp;lt;/latest&amp;gt;
        &amp;lt;/search&amp;gt;
        &amp;lt;default&amp;gt;Mar-23-18&amp;lt;/default&amp;gt;
        &amp;lt;initialValue&amp;gt;Mar-23-18&amp;lt;/initialValue&amp;gt;
      &amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Jan 2018 06:22:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-current-month-as-default-value-in-drop-down/m-p/288641#M18264</guid>
      <dc:creator>katrinamara</dc:creator>
      <dc:date>2018-01-05T06:22:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to set current month as default value in drop-down?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-current-month-as-default-value-in-drop-down/m-p/288642#M18265</link>
      <description>&lt;P&gt;Hi @katrinamara ,&lt;/P&gt;

&lt;P&gt;Can you please try below code in your dashboard?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;Dropdown Select&amp;lt;/label&amp;gt;
  &amp;lt;search&amp;gt;
    &amp;lt;query&amp;gt;| makeresults  | eval current_month = strftime(now(),"%B-%Y") | table current_month&amp;lt;/query&amp;gt;
    &amp;lt;done&amp;gt;
      &amp;lt;set token="tkn_current_month"&amp;gt;$result.current_month$&amp;lt;/set&amp;gt;
    &amp;lt;/done&amp;gt;
  &amp;lt;/search&amp;gt;
  &amp;lt;fieldset submitButton="false"&amp;gt;
    &amp;lt;input id="input1" type="dropdown" token="from_tok" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;From&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;$tkn_current_month$&amp;lt;/default&amp;gt;
      &amp;lt;fieldForLabel&amp;gt;month&amp;lt;/fieldForLabel&amp;gt;
      &amp;lt;fieldForValue&amp;gt;month&amp;lt;/fieldForValue&amp;gt;
      &amp;lt;search&amp;gt;
        &amp;lt;query&amp;gt;| makeresults | eval month="01,02,03,04,05,06,07,08,09,10,11,12" | makemv delim="," month | stats count by month | eval month = "01-".month."-2018" | eval month = strftime(strptime(month."-2018","%d-%m-%Y"),"%B-%Y") | table month&amp;lt;/query&amp;gt;
      &amp;lt;/search&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have added below code which is set current month value in token, which is used as default value in dropdown.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;search&amp;gt;
        &amp;lt;query&amp;gt;| makeresults  | eval current_month = strftime(now(),"%B-%Y") | table current_month&amp;lt;/query&amp;gt;
        &amp;lt;done&amp;gt;
          &amp;lt;set token="tkn_current_month"&amp;gt;$result.current_month$&amp;lt;/set&amp;gt;
        &amp;lt;/done&amp;gt;
      &amp;lt;/search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 12:37:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-current-month-as-default-value-in-drop-down/m-p/288642#M18265</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2018-01-05T12:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to set current month as default value in drop-down?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-current-month-as-default-value-in-drop-down/m-p/288643#M18266</link>
      <description>&lt;P&gt;Hi, the value for drop-down should come from the Leave Start Date and Leave End Date in our data. I don't think I can declare the month as shown above.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 01:49:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-current-month-as-default-value-in-drop-down/m-p/288643#M18266</guid>
      <dc:creator>katrinamara</dc:creator>
      <dc:date>2018-01-11T01:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to set current month as default value in drop-down?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-current-month-as-default-value-in-drop-down/m-p/288644#M18267</link>
      <description>&lt;P&gt;Hi @katrinamara&lt;/P&gt;

&lt;P&gt;I have a similar requirement . Did you get this working ?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 13:47:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-set-current-month-as-default-value-in-drop-down/m-p/288644#M18267</guid>
      <dc:creator>surekhasplunk</dc:creator>
      <dc:date>2018-04-20T13:47:43Z</dc:date>
    </item>
  </channel>
</rss>

