Qlik Community

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Tell us which business and trade publications you read most regularly: RESPOND NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
srihitha
Contributor III
Contributor III

Peek with date value

Hi,

Can someone please explain why Peek function has to be used with date to get its value into a variable.

I know the general purpose of Peek function but couldn't understand why is it used to extract date value into a variable.

Also, although date variable is getting extracted correctly, nothing is getting loaded into my final table tab3.

Tab3 must have same data as Tab1

tab1:
load * Inline
[Dat, Countr, Produc, Amoun
2022-01-20, Canada, Washer, 6
2018-07-08, Germany, Anchor bolt, 10
2018-07-14, Germany, Anchor bolt, 3
2018-08-31, France, Nut, 2
2018-09-02, Czech Republic, Bolt, 1
2019-02-11, Czech Republic, Bolt, 3
2019-07-31, Czech Republic, Washer, 6
2020-03-13, France, Anchor bolt, 1
2020-07-12, Canada, Anchor bolt, 8
2020-09-16, France, Washer, 1]

tab2:
load max(Dat) as maxdate resident tab1;
let vmaxdate=Peek('maxdate');

trace $(vmaxdate);

tab3:
load * resident tab1 where Dat<$(vmaxdate);

 

Labels (3)
2 Solutions

Accepted Solutions
FruzoCrew
Creator
Creator

Use  NoConcatenate and drop the first table.

tab1:
load * Inline
[Dat, Countr, Produc, Amoun
2022-01-20, Canada, Washer, 6
2018-07-08, Germany, Anchor bolt, 10
2018-07-14, Germany, Anchor bolt, 3
2018-08-31, France, Nut, 2
2018-09-02, Czech Republic, Bolt, 1
2019-02-11, Czech Republic, Bolt, 3
2019-07-31, Czech Republic, Washer, 6
2020-03-13, France, Anchor bolt, 1
2020-07-12, Canada, Anchor bolt, 8
2020-09-16, France, Washer, 1];

tab2:
load max(Dat) as maxdate resident tab1;
let vmaxdate=Peek('maxdate');

trace $(vmaxdate);

NoConcatenate
tab3:
load * resident tab1 where Dat<$(vmaxdate);

drop Table tab1;

View solution in original post

vinieme12
Champion III
Champion III

if this worked for you, please close the thread by accepting it as solution 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.

View solution in original post

3 Replies
FruzoCrew
Creator
Creator

Use  NoConcatenate and drop the first table.

tab1:
load * Inline
[Dat, Countr, Produc, Amoun
2022-01-20, Canada, Washer, 6
2018-07-08, Germany, Anchor bolt, 10
2018-07-14, Germany, Anchor bolt, 3
2018-08-31, France, Nut, 2
2018-09-02, Czech Republic, Bolt, 1
2019-02-11, Czech Republic, Bolt, 3
2019-07-31, Czech Republic, Washer, 6
2020-03-13, France, Anchor bolt, 1
2020-07-12, Canada, Anchor bolt, 8
2020-09-16, France, Washer, 1];

tab2:
load max(Dat) as maxdate resident tab1;
let vmaxdate=Peek('maxdate');

trace $(vmaxdate);

NoConcatenate
tab3:
load * resident tab1 where Dat<$(vmaxdate);

drop Table tab1;

vinieme12
Champion III
Champion III

You are missing the single quotes,

And max maybe returning a numerical value of the date , so reformat it to date

 

tab2:

load Date(max(Dat)) as maxdate resident tab1;

let vmaxdate=Peek('maxdate');

NoConcatenate
tab3:
load * resident tab1 where Dat<'$(vmaxdate)';

drop Table tab1;

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
vinieme12
Champion III
Champion III

if this worked for you, please close the thread by accepting it as solution 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.