Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
How do I set up a calendar object that allows me to limit data based on selected start and end dates?
New to Qlikview so any help is greatly appreciated!
Have a look through some of the 'how-to's this one should help you:
Most people would probably handle it with variables and actions. Make two variables and trigger an action when either is entered that selects all dates in the range.
I'd probably handle it with data. In addition to the calendar table, add a from date table and a to date table. Every date in the from date table should map to itself and every later date. Every date in the to date table should map to itself and every earlier date. Add calendar objects for the from date field and the to date field. Selecting a from date and to date will now automatically narrow down to that date range just based on QlikView's normal associative logic. Attached is an example of that approach. In case you're only using personal edition, here's the script:
[Calendar]:
LOAD date(makedate(2010)+recno()-1) as Date
AUTOGENERATE 365
;
[FromDate]:
LOAD
Date as FromDate
,date(Date+iterno()-1) as Date
RESIDENT [Calendar]
WHILE date(Date+iterno()-1) < makedate(2011)
;
[ToDate]:
LOAD
Date as ToDate
,date(Date-iterno()+1) as Date
RESIDENT [Calendar]
WHILE date(Date-iterno()+1) > makedate(2009,12,31)
;
Well, I was unable to get it to work with a select action, because there's no "clear this field, then select" ability so far as I know. You can clear all fields, which might work for the example, but wouldn't be any good in the real world. So I resorted to doing the selection with a triggered macro:
sub DateRange
set field = activedocument.fields("Date")
field.clear
field.select "=Date>=FromDate and Date<=ToDate"
end sub
John,
Been meaning to thank you for this...I figured out how to do it using an calculated dimension that taps into a variable.
Thanks for the quick reply!!
LD