0

Can I dynamically set default value to date picker?

Hello, 

After creating a date-picker, there is an option to set the "Default Value" for it. And this is a static value. I'm wondering, is there an option to set this "Default Value" dynamically?

Here is my user-case: I'm having two date-pickers ("start date" and "end date") and by default I want them to have the values:

start date - to have the value of first day of the last month

end date - to have the value of the last day of the last month

If using the standard "static" way, I should update these values manually every time when we are in a new month, so I'm wondering if there is an option this to be done with formulas somehow?

* bonus question: is there a possibility to dynamically disable the date pickers, or any other way, to prevent the scenario for value of the "end date" to be before "start date"? (I want "start date" always to be before the "end date" and user to not be able to select dates otherwise).

NOTE: I don't want to use any other controls like "drop-downs". I want to have only these two visible elements (date-pickers) for the user.

Regards,

6 comments

  • 0
    Avatar
    Josh Cohen-Collier

    Hi Ivan,

    Thanks for posting in our Community!

    Unfortunately, doing this is not something that is possible.
    The date picker will always remember the last value the user picked, after the default value is changed(default value only works the very first time the input control is used).

    However, there is an open feature request for this, that I have added to, so that you can be updated via email.

    Hope this helps!


    Best regards,
    Joshua
    _________________
    Joshua Cohen-Collier,
    Technical Support Engineer, Klipfolio

  • 0
    Avatar
    Ivan Stojanov

    Hello Joshua,

    Thank you for your comment.

    I will look forward to the update.

    Regards,

    Ivan

  • 0
    Avatar
    Gavin Harmon

    I figured out how to do just this and I use it for my dashboards.


    Set date picker to variable: $examplevar

    Create a new user input and make it hidden also set this to variable $examplevar

    set the values of this user input to your default value ie

    datevalue(today(),"M/d/yyyy")

    Now on refresh this will populate in all your klips but also your date picker :)

    -Gavin

     

     

     

     

     

  • 0
    Avatar
    Franck van der Sluis

    Unfortunately, this is not a feature provided by Klipfolio.

    However, there is a very simple workaround that helps you achieving dynamic set date ranges in your Klips.

    1. Create a date-picker with the variable startDate
    2. In your klip formulas, check if the startDate variable is set by the user: IF(startDate = "", dynamicVal, $startDate)
    3. In above formula, replace "dynamicVal" with your dynamic set date. "TODAY() for instance"
    4. This checks if the datepicker is set to a value by the user. If not, use the dynamic value. if yes, use the picked value.

    Cheers

  • 0
    Avatar
    Joris Le Blansch

    Hi Franck,

    I like this approach, it looks simple enough for what I need (I need startdate as today-30 and enddate as today). However, I can't get it to work. Where do you add the formula ? A date picker component does not allow for underlying hidden data... I tried Gavin's solution above also without succes. Can you please detail a bit more ?

    Kind regards,

    Joris.

  • 1
    Avatar
    Matthew Cahill

    Hey Joris, 

    I ran into the same issue and the above did not help me, in the same way it didnt for you. 

    i wanted my dashboard to always set the values to 'Month to Date' for my dashboard when a person opens the link or dashboard. 


    I did find a solution however, using the user input control as a button. 

    Using Gavin Harmon's solution, I then set the hidden input as a button with the following 'Value' formula. 

    StartDate: 
    if($startdate=DATE_STARTOF(TODAY(),"3"),DATE_STARTOF(TODAY(),"3"),DATE_STARTOF(TODAY(),"3"))

    EndDate: 
    if($endate=TODAY(),TODAY(),TODAY())

    It seems to work for me, even with a published link to the dashboard, let me know if that has worked for you. 

Please sign in to leave a comment.