Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
If you are a Qlik Insight Bot user, join this collaborative group: JOIN GROUP
Not applicable

How to set a default date for Calendar object?

Hi there.

Is there a way to set an initial/default date to the Calendar Object?

Ie. When I open up the .qvw file, Iike the Date to be pre-selected to TODAY's date?

Thank-you for your support.

- Simon.

Tags (1)
8 Replies
Highlighted
Not applicable

How to set a default date for Calendar object?

Simon,

I don't believe there is a way to set default values for any field, including a calendar object, which is unfortunate. The only way I know of to accomplish what you want is to have a macro that makes that selection for you when the document loads, or when you enter a tab. I don't remember the exact syntax off the top of my head, but it is something like:

ActiveDocument.Fields("Date").Select today()

You may be able to do a similar thing with a bookmark, which would be preferable to a macro as macros are single-threaded.

hope this helps,

sjprows

Highlighted
Not applicable

How to set a default date for Calendar object?

Similar to sjprows' suggestion, you could use a Trigger instead of a macro. You could set a Trigger for OnOpen and make the Today() selection in your date field. I believe Triggers are the preferred solution to some of the issues with using macros. Triggers are only available in QlikView 9.

Highlighted
Not applicable

How to set a default date for Calendar object?

You can base your calendar value on a variable. e.g. TodayDateVar

This variable will be equal to today() (In variables window add TodayDateVar = Date(Today())
So when you open your application your variable will take your value.

Highlighted
Not applicable

How to set a default date for Calendar object?

Got a step by step procedure for this?

Highlighted
MVP & Luminary
MVP & Luminary

How to set a default date for Calendar object?

Highlighted
Not applicable

Re: How to set a default date for Calendar object?

I personally like the behavior of the below, but it depends on your reload frequency.  It resets the slider to today's date with each reload.  The user can then choose a different date between the min/max options.  This looks like it's working for me, but if there is a different better option, please reply.

in the load script:

LOAD
Min(BDate) as MinDate,
Max(EDate) as MaxDate
RESIDENT your table;

LET vMinDate = Num(Peek('MinDate', 0, 'MinMax'));
LET vMaxDate = Num(Peek('MaxDate', 0, 'MinMax'));
LET vToday = today();

In the calendar slider properties:

Set variable = vToday

set min and max equal to vMinDate and vMaxDate

Highlighted
Valued Contributor II

Re: How to set a default date for Calendar object?

it is simple, by assigning calendar object variable to reload time date and saving the application.

For eg:

vCalendarDate=date (reload ())

(And giving the max value of calendar object to date of reload time)

Highlighted
New Contributor III

Re: How to set a default date for Calendar object?

EDIT: Found the problem. Source data date field is a timestamp. I hadn't added floor to the date, so was being stored with timestamps but was not displaying with times.

===

Hi Rob, QV learner here.

That link worked for me, however, it removed all entries from the table except for a single matched instance of the day I wanted (yesterday).


I do have a key, 2 in fact, but I seem to lose the relationship between those dates.

I do have a master calendar.

If I add 2 select fields for month and day, and manually choose yesteErday, again, I lose table entries except one instance.

Am using a table box as it is supporting data