Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
qlikviewforum
Creator II
Creator II

Loading latest 2 weeks of data into the dashboard.

Hi All,

I have number QVD's in below format. I want to load only latest 2 QVD's into our dashboard. Also code should behave in such a way that when we want to load first week of 2014 and last week of 2013. Can someone help me out for the same please?

Regards,

Rikab

4 Replies
Not applicable

Hi,

The below expression will give the start date of last week.

=MakeWeekDate(WeekYear(Now()),Week(Now())-1)

Replace the Now() function with your Date field to get the latest 2 weeks of data. Please let me know if I am not understand you correctly.

qlikviewforum
Creator II
Creator II
Author

I think you have misunderstood my requirement. My question was we have weekly QVD's and i pick only 2 qvd and load into the dashboard.

Gysbert_Wassenaar

Something like this maybe:

LET vCurrentWeek = week(today());

LET vPreviousWeek = week(today()-7);

LET vCurrentYear = year(today());

LET vPreviousYear = year(today()-7);

LET vCurrentFile = 'datafile_$(vCurrentYear)_$(vCurrentWeek).qvd';

LET vPreviousFile = 'datafile_$(vPreviousYear)_$(vPreviousWeek).qvd';

LOAD * from '$(vCurrentFile)' (qvd);

LOAD * from '$(vPreviousFile)' (qvd);

Your files probably don't have names like 'datefile_2013_42.qvd' so you'll have to change the vCurrentFile and vPreviousFile variables accordingly.

If your data files don't have the week number in their names but use dates then you'll have to figure out which part of the dates you need to determine which files to load.


talk is cheap, supply exceeds demand
qlikviewforum
Creator II
Creator II
Author

In my data file I have below fields. I don't have anything like date field in my data file. So using the ReloadTime() to find the Year and Week to have consistent data.

Employee

Employee:

Field1,

Field2,

Week(ReloadTime()) as Week,

Year(ReloadTime()) as Year

From [Source Table]

From the above I am getting the Year(vYear) and Week(vWeek) using peek and storing it into a variable. Then we are using the same while storing the qvd in the above format.

Store TableName into TableName.$(Year)_$(Week).qvd (qvd);

So week(today()-7) my not here. Can you please suggest some other way doing this.

Today we are loading only 2 weeks of data, tomorrow they may ask to load 8 weeks of data. So the code should be flexible enough.

When we are trying to load the first 4 weeks of current year and last 4 weeks of previous year above code my not work. Please advice on this...

: