Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Getting application to default to current date when you load in future data

We have build an application where we load in forecast data, so we have data till end of Dec 10. I would like to set the pages to default to the most recent actual data date so for today it would be 11th August. Any suggestions on how we do this? When we use Max date it gives us 31st Dec

Thanks

7 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

=Today()?

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

We have tried this and it gives us a date in December, which doesn't make much sense as we don't have actual data

Not applicable
Author

Assuming that you have last day's data whenever reloaded, can you use 'ReloadTime()' and subtract one day from it?

Not applicable
Author

Hi,

I do it this way:

1. At end of scripts, when all data has been loaded...

// Calculate Last Transaction date
LastTransDateTemp:
load distinct
max(TranDate,1) as LastTranDate
resident TransactionLines;

let vLastTransactionDate = date(peek('LastTranDate',-1,'LastTransDateTemp'));

drop table LastTransDateTemp;

2. Then I created a macro

sub StartSelection
LatestTranDate = ActiveDocument.Variables("vLastTransactionDate").GetContent.string
ActiveDocument.Fields("Year").Select Year(LatestTranDate)
ActiveDocument.Fields("Month").Select left(MonthName(Month(LatestTranDate)),3)
ActiveDocument.Fields("Day").Select Day(LatestTranDate)
end sub

3. Then in the Macro tab of the Dicument Properties, Document Event Triggers highlight 'OnOpen' and select the StartSelections macro

Note that, for my purposes, I seperate the Year, Month and Day fields. Each time I open the QlikView document it selects transactions for the latest Year, Month and Day of the available transactions

Hope this gives you some idea.

Raisin

Not applicable
Author

oh this sounds like it might work. What do i need to type into the search string to let it know it needs to subtract a day is it ReloadTime(-1)

Not applicable
Author

date(ReloadTime()-1,'MM/DD/YYYY')

This will give you the last day's date.

Not applicable
Author

You don't need to since it uses the date of the latest transaction