Dashboards & Visualizations

How to set current year in the drop down menu as a default?

YuliyaVassilyev
Explorer

I can do it manually, but prefer to set current year as a default year in my drop down menu. Here is some of source code:

  <label>Year</label>
  <default>2020</default>
Tags (1)
0 Karma
1 Solution

kamlesh_vaghela
SplunkTrust
SplunkTrust

@YuliyaVassilyeva

Can you please try below XML?

<form>
  <label>Default Year</label>
  <search>
    <query>| makeresults | eval current_year = strftime(now(), "%Y")</query>
    <done>
      <set token="current_year">$result.current_year$</set>
    </done>
  </search>
  <fieldset submitButton="false">
    <input type="dropdown" token="field1">
      <label>Year Selection</label>
      <choice value="2019">2019</choice>
      <choice value="2020">2020</choice>
      <choice value="2021">2021</choice>
      <default>$current_year$</default>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>
        Current Year: $current_year$
      </html>
    </panel>
  </row>
</form>

View solution in original post

kamlesh_vaghela
SplunkTrust
SplunkTrust

@YuliyaVassilyeva

Can you please try below XML?

<form>
  <label>Default Year</label>
  <search>
    <query>| makeresults | eval current_year = strftime(now(), "%Y")</query>
    <done>
      <set token="current_year">$result.current_year$</set>
    </done>
  </search>
  <fieldset submitButton="false">
    <input type="dropdown" token="field1">
      <label>Year Selection</label>
      <choice value="2019">2019</choice>
      <choice value="2020">2020</choice>
      <choice value="2021">2021</choice>
      <default>$current_year$</default>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>
        Current Year: $current_year$
      </html>
    </panel>
  </row>
</form>

yvassilyeva
Path Finder

That worked. Thank you!

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

cool @YuliyaVassilyev 

Please accept it for closing the question. 

Thanks

0 Karma

yvassilyeva
Path Finder

@kamlesh_vaghela Your answer works, but there is nowhere here to accept the answer...

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@yvassilyeva 

 

This question raised by YuliyaVassilyev user.  So you have to login with YuliyaVassilyev for accepting. 🙂 

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...