Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Dynamic date selection using bookmarks

Is there a way to include a variable date selection in a bookmark ?

We have a Qlikview file that contain dates and registered hours for a number of people.

On a weekly basis, registered hours are analysed.

We want to create a bookmark that will select the following date range :

=> Select last week (7 days starting from yesterday)

=> Select from beginning of the month untill yesterday

Can it be achieved using a bookmark ?

I do not want to use set analysis as I want the selection to be valid for my complete QV file.

Setting the date range using a macro function is not really an option as different scenario's may exist (beginning of month, last week, last fortnight, ...)

1 Solution

Accepted Solutions
pat_agen
Specialist
Specialist

try something like this in the search box, replace "Timestamp" with the name of your date field

     =if(floor(Timestamp)>floor(today(2)-8) and floor(Timestamp)<floor(today(2))  ,1)

the parameter 2 inside the today() function means it will take the time teh document was opened so it shouldn(t be constantly evaluating itself.

another alternative is to set a vraible i your script - especailly if the data is getting reloaded everyday.

the floor() functions get around problems caused by formatting and the bits of days you get in timestamps.

View solution in original post

3 Replies
pat_agen
Specialist
Specialist

hi,

are you able to write the code for your two selections?

if you can do this try the following.

click on a list box containing your dates. Click on search or just start typing. Make sure your search query begins with the equal sign "=" followed by the code for your select. You will know if it is working because the corrcet dates will be selected.

Save this as your bookmark.

Qv will store your search query in the boomark and not the dimesnion elements this returns. thus making your bookmark dynamic.

To check this open a current selections object and select your bookmark.

Not applicable
Author

My formula should be something like this :

=<today()-1 > today()-8

However, even the function = today() selects too much data. I would expect the system to select only today's date in this case but it doesn't. I want to select all the dates between yesterday and 7 days before yesterday by means of a dynamic select.

pat_agen
Specialist
Specialist

try something like this in the search box, replace "Timestamp" with the name of your date field

     =if(floor(Timestamp)>floor(today(2)-8) and floor(Timestamp)<floor(today(2))  ,1)

the parameter 2 inside the today() function means it will take the time teh document was opened so it shouldn(t be constantly evaluating itself.

another alternative is to set a vraible i your script - especailly if the data is getting reloaded everyday.

the floor() functions get around problems caused by formatting and the bits of days you get in timestamps.