Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Flag is not getting created correctly when comparing two dates??

Hi All,

I am very new to qlik please suggest me something for the below issue:

I need to create a flag containing values Y and N.

I have created these two columns Date and Latest Date from csv file Date_key column and saving in qvd file.

my code is like this:

Date               Latest Date    Flag

22/08/2016        22/08/2016   Y

23/08/2016        22/08/2016   N

24/08/2016         22/08/2016   N

25/08/2016         22/08/2016   N


and the i am using the below code to create the flag


Load

     if(Date = Latest Date,'Y','N') as MaxDate

Resident Dummy;



Thanks in Advance.

4 Replies
Not applicable
Author

Hi,

Its output is coming like this:

Date               Latest Date    Flag

22/08/2016        22/08/2016   Y

23/08/2016        22/08/2016   N

24/08/2016         22/08/2016   Y

25/08/2016         22/08/2016   N


which is not correct.

MK9885
Master II
Master II

Isn't that correct?

You wanted Y or N as flag.

You have condition placed as well...then what more you need?

You want Min & Max or Flag?

Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II

Hi,

My script :

LOAD

If(Date = [Latest Date], 'Y', 'N') as tt,

Date,

[Latest Date]

INLINE [

Date    ,           Latest Date

22/08/2016,        22/08/2016

23/08/2016 ,       22/08/2016 

24/08/2016 ,        22/08/2016 

25/08/2016 ,        22/08/2016 

];

And the result :

Date Latest Date tt
22/08/201622/08/2016Y
23/08/201622/08/2016N
24/08/201622/08/2016N
25/08/201622/08/2016N

Aurélien

Help users find answers! Don't forget to mark a solution that worked for you!
Not applicable
Author

Hi all,

Thanks for your replies.

have got the solution for it.

i am creating a temp table to find out the max date:

RecentWeekvalue:

Load

  Date(max(weekendDate), 'DD/MM/YYYY') as RecentWeek

Resident  Calendar;

store this value in variable:

we need to use peek because it will get the first value from max.

let vRecentWeek =Peek('RecentWeek',0,'RecentWeekvalue');

and then compare it :

and important is keep your variable in single quotes only then it will work:

IF (weekendDate = '$(vRecentWeek)','Y','N') as MostRecentWeek,

Thanks all for the solutions.