Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Setting custom date variable from resident table

Hi All,

I am trying to load date variables for 'yesterday' i.e. ThisWeek etc. from a resident calendar table but it doesn't seem to work..

Does nyone have any ideas pelase ?

Thanks in advance !! 🙂

Bob

OP_DATE:

LOAD Date ,

Week,

Year,

Period


FROM

C:\Analyser\Data\Cal.csv

(
txt, codepage is 1252, embedded labels, delimiter is ',', msq);



Variables:

Load Week AS ThisWeek Resident OP_DATE where Date  = today(2)-1 ;

Load Period AS ThisPeriod Resident OP_DATE where Date  = today(2) -1 ;

Load Year AS ThisYear Resident OP_DATE where Date  = today(2) -1; 

1 Solution

Accepted Solutions
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Try this.

OP_DATE:


LOAD Date ,

Week,

Year,

Period


FROM

C:\Analyser\Data\Cal.csv

(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

Variables:

Temp:
Load distinct Week AS ThisWeek Resident OP_DATE where Date  = today(2)-1 ;

Let vThisWeek = peek('ThisWeek',0,'Temp');

Drop table Temp;

Temp:
Load distinct Period AS ThisPeriod Resident OP_DATE where Date  = today(2)-1 ;

Let vThisPeriod = peek('ThisPeriod',0,'Temp');

Drop table Temp;


Temp:
Load distinct Year AS ThisYear Resident OP_DATE where Date  = today(2)-1 ;

Let vThisYear = peek('ThisYear',0,'Temp');

Drop table Temp;

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!

View solution in original post

2 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

     Try this.

OP_DATE:


LOAD Date ,

Week,

Year,

Period


FROM

C:\Analyser\Data\Cal.csv

(txt, codepage is 1252, embedded labels, delimiter is ',', msq);

Variables:

Temp:
Load distinct Week AS ThisWeek Resident OP_DATE where Date  = today(2)-1 ;

Let vThisWeek = peek('ThisWeek',0,'Temp');

Drop table Temp;

Temp:
Load distinct Period AS ThisPeriod Resident OP_DATE where Date  = today(2)-1 ;

Let vThisPeriod = peek('ThisPeriod',0,'Temp');

Drop table Temp;


Temp:
Load distinct Year AS ThisYear Resident OP_DATE where Date  = today(2)-1 ;

Let vThisYear = peek('ThisYear',0,'Temp');

Drop table Temp;

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Thanks Kaushik

Works perfectly !!!!