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

Historical Data In Qlikview

Hi,

I have data set which keeps changing everyday. But, the data set does not have date field when it is changed. 

Example Data set:

Last week (week 45) , data looks like this:

Data1:

RegionProductSaleCost
AsiaApples10050
AsiaOranges100100
AsiaMangoes20050
USAApples100100
USAOranges20050
USAMangoes200100
EuropeApples20050
EuropeOranges100100
EuropeMangoes20050
EuropeBananas30050

 

Script:

Load

Region,

Product,

Sale,

Cost,

(Sale-Cost)  as Profit

From Data1:

Result Table:

It will be a straight table with dimensions as region and measure as Sum(profit).

RegionProfit
Asia200
Europe550
USA250

 

But all the above results are for week 45. Now for  week (46), my data may look like this:

RegionProductSaleCost
AsiaApples100100
AsiaOranges150200
AsiaMangoes200100
USAApples250200
USAOranges300100
USAMangoes350500
EuropeApples400100
EuropeOranges450200
EuropeMangoes300100
EuropeBananas300100

 

I would like my result table to look the same way as above but time i would like to see my old results for week 45 as well:

RegionWeekProfit
Asia4650
Europe46950
USA46100
Asia45200
Europe45550
USA45250

 

How do i achieve this?

Remember,  the week number is unknown. I would that to be a calculated field based on the run date of the script.

Can someone help me how to do this?

Thanks,

Vidya

 

 

Labels (2)
2 Replies
juraj_misina
Luminary Alumni
Luminary Alumni

Hi,

you can use Today() and Week() function to calculate week.

Load
Week(Today()) as Week, //shows just week number, like 45
WeekName(Today()) as WeekName //shows year as well: 2018-45
*
From SourceTable;

Be carefull with first week of year, it can get tricky (but there's a setting for that). See Broken Weeks.

 

Vegar
MVP
MVP

You can create a week dimension in the scripted as Juraj_misina wrote before me.

Then you will need to store your weekly extract into qvd files. I would recommend you to look into the topic incremental load to limit which data you need to store away for the future.