1

Default value for Input Control with Date Picker type

Is it possible to specify default date for Date Picker? I didn't manage how to accomplish this.

There is default value option available for user if you assign variable to Date Picker. However as far as I can see this option doesn' work.

I have specified default "01/01/2016", but it is not shown in Date Picker as default value.

Could you, please, clarify?

8 comments

  • Avatar
    Janice Janczyn Official comment

    Hi Pavel,

    The Default Value setting for User Input Controls, including Date Pickers, sets the initial value for the first time the klip is added to a dashboard. Depending on your scenario, you can set a date to default to the first of the year (for example) in your klip formulas. One approach is to use 2 User Input Controls, a Date Picker and a Drop-Down List that allows a user to, for example, select one of 

    • Default
    • Use Date Picker

    Where the formulas treat Default as 01/01/2016 and Use Date Picker looks instead at the date chosen from the Date Picker.

     

    Thanks,

             Janice

  • 0
    Avatar
    Martin Matuška

    Hi Janice,

    could you posiibly show us example of formulas you mentioned in your post? And possibly add some instructions how to do it? I am stugglling a bit.

    Martin

  • 0
    Avatar
    Andre Freitag

    Hi Janice,

    i´m also struggeling with this feature. I the following Sparkline:

     

    By default I want to show the first Date at Data Source on "$start_date" und today in "$end_date". How can i use variables as "Default Value"? 

  • 1
    Avatar
    Janice Janczyn

    Hi Martin,

    1. Create a multicomponent klip with 2 User Input Control klips: 

    • a Drop-Down list with Values set to ARRAY( "Default Date", "Use Date Picker", sets (for example) defaultDate variable
    • a Date Picker, sets (for example) startDate variable

    2. In your formulas, check for $defaultDate. If user selected Default Date, use the default date of your choice. If the user selected Use Date Picker, use $startDate. For example:

       IF( $defaultDate = "Default Date",

             SELECT( data, date= "01/01/2016"),

             SELECT( data, date= $startDate) )

     

    Note that if your $defaultDate variable could be set to one of more than 2 variables, you should use a SWITCH instead of an IF statement since nested IFs are inefficient and can become difficult to read and maintain.

     

    Thanks,

         Janice

  • 0
    Avatar
    Janice Janczyn

    Hi Andre,

    You would add the same Drop-Down list described in my response to Martin and refer to the $defaultDate variable in your formulas, for example (assuming $startDate & $endDate are in Epoch format):

    IF( $defaultDate = "Default Date",

             SELECT( data, BETWEEN( dates, MIN( DATE(dates,"yyyy-MM-dd")), TODAY() ),

             SELECT( data, BETWEEN( dates, $startDate, $endDate) ) )

    The MIN function returns the minimum value from the data passed to it, in this example, this would be the earliest date in the datasource.

    Thanks, 

          Janice

     

  • 0
    Avatar
    Martin Matuška

    Hi, it works for me. One more question. Could we do same, but with buttons?

    I mean, not with  Drop-Down list with values( "Default Date", "Use Date Picker"), but with button last 30 days, last 90 days, last year, etc.

    M.

  • 0
    Avatar
    Janice Janczyn

    Hi Martin, I assume you mean multiple buttons, one for each time period?  Technically this could be done, however it would add complexity to your formulas since each button requires its own unique variable. 

    Thanks,

          Janice

  • 1
    Avatar
    Keith Harrison

    New user... want to keep it simple so I'm asking a simple question:

    In the date picker section, option for default date, in that section, I've put random dates but is there not a command/function I can use such as:

    Start date default = >30 days

    End date default = Today

    Something simple like this?

    • Any videos on this I could see would be awesome??
    • Or even a default value of "all data" would be fine?

     

Please sign in to leave a comment.