Dashboards & Visualizations

How to set the default value of an input number field to current day's date in Dashboard?

Sharma21
Explorer

I have defined a number.input field in Dashboard Studio (Version:9.0.2) so that the user can select a number representing a date (between 1-31). I want the date to be set to current day's date by default when the user opens the dashboard..

But "defaultValue": "$token_curr_date$" in the code below throws error  - Incorrect Type. Expected "number"

{
    "options": {
        "defaultValue": "$token_curr_date$",
        "token": "num_date",
        "min": 1,
        "max": 31
    },
    "title": "Select Date",
    "type": "input.number"
}
 
In "dataSources" I have defined below search and token:
 
        "ds_current_date": {
            "type": "ds.search",
            "options": {
                "query": "| makeresults | eval token_curr_date=strftime(now(), \"%d\") | fields token_curr_date"
            },
            "token": "token_curr_date"
        }
 
How do set the default value of input.number to current date? 
Labels (2)
0 Karma

Sharma21
Explorer

Not working still. I am thinking that its not even recognizing the token value. Anything wrong with the way I am defining the token or maybe I need to initialize it before it can be referenced?

richgalloway
SplunkTrust
SplunkTrust

The strftime function returns a string rather than an integer expected by defaultValue.  Try converting the string into a number.

...
 "options": {
                "query": "| makeresults | eval token_curr_date=tonumber(strftime(now(), \"%d\")) | fields token_curr_date"
            },
...

 

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Splunk Observability Cloud’s AI Assistant in Action Series: Analyzing and ...

This is the second post in our Splunk Observability Cloud’s AI Assistant in Action series, in which we look at ...

Elevate Your Organization with Splunk’s Next Platform Evolution

 Thursday, July 10, 2025  |  11AM PDT / 2PM EDT Whether you're managing complex deployments or looking to ...

Splunk Answers Content Calendar, June Edition

Get ready for this week’s post dedicated to Splunk Dashboards! We're celebrating the power of community by ...