Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Join this live chat April 6, 10AM EST - QlikView to Qlik Sense REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
bushpalaamarnat
Creator
Creator

how to create snapshot of current week data as qvd dynamically

Hi all,

Could you help, every week we get data in the following format.

   

WeeksMaterial codeLocation
W18-18ABCInd
W18-18BCDUSA
W18-18ABCUK
W19-18BCDInd
W20-18DCEUK
W20-18ABCUK

for which the first week we call it as current week, for example the above table has W18-18 as the week which is current week for this year. Now every week i need to save a snap shot of the current week data as a qvd for next week reference.

Like that i need to create 6 week data which will become a 6 week history.

Could you please advise on how to write a back end  to store data.

1 Solution

Accepted Solutions
qvraj123
Creator II
Creator II

Are you trying to save the each weeks data into a QVD file?

1) for the first time load the data into the QVD file - Lets say you are loading the data today into a QVD file

   for identifying the current week - something based on the date or some way to identify the current week so you don't have to hard code

2) next week when you have the new data - read the data from the QVD that you have in step 1

then add the new data to the same QVD

this is just appending new data to the old data and saving the QVD file

View solution in original post

6 Replies
Miguel_Angel_Baeyens

Key here is how to create the field for the week as you have it in your data model.

Without testing, looks like it could be retrieved during the load script from any timestamp using

'W' & Week(DateField) & '-' & Right(Year(DateField), 2) AS Weeks

Once you have it, you can do a loop for each possible value and store every week in a different QVD:

AllWeeks:

LOAD Concat(DISTINCT Chr(39) & Weeks & Chr(39), ',') AS AllWeeks

FROM Table.qvd (qvd); // whatever the source for the Weeks field above mentioned

LET vAllWeeks = FieldValue('AllWeeks', 1);

For Each vWeek In vAllWeeks // check here the $() if required

Table:

LOAD *

FROM Source

WHERE Weeks = vWeek; // again, check for $()

STORE Table INTO [Data_$(vWeek).qvd] (qvd);

DROP Table;

Next

YoussefBelloum
Champion
Champion

Hi,

it depends on your needs..

you can store the entire table each week (including the current week and the previous weeks) and store it with actual week number as indication.

just use the STORE command with this syntax:

LET vStore= Week(Today());

Store TABLE_NAME Into [your_path\TABLE_NAME_$(vStore).qvd];

bushpalaamarnat
Creator
Creator
Author

yes,  you correct - "you can store the entire table each week (including the current week and the previous weeks) and store it with actual week number as indication.


This is my need.


what is the best way to do this sir.


qvraj123
Creator II
Creator II

Are you trying to save the each weeks data into a QVD file?

1) for the first time load the data into the QVD file - Lets say you are loading the data today into a QVD file

   for identifying the current week - something based on the date or some way to identify the current week so you don't have to hard code

2) next week when you have the new data - read the data from the QVD that you have in step 1

then add the new data to the same QVD

this is just appending new data to the old data and saving the QVD file

View solution in original post

bushpalaamarnat
Creator
Creator
Author

Sir, the logic which you specified is the absolute one. Thank you!

'W' & Week(DateField) & '-' & Right(Year(DateField), 2) AS Weeks

vongalaprashant
Contributor III
Contributor III

Hi Raj,

Need your help.

Every current  tuesday I have to store previous week data(Monday to sunday) and this data should not include current monday data ?

I tried :

If(weekday(today)='Tue'

then store------------

but this is storing monday data also.

can any one help me ?

Thanks In advance,.

Regards,

reddy.