Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
vikasshana
Creator II
Creator II

If condition is not doing the changes what I'm expecting

Hi,

I do have the below Inline load statement.

testing:
Load * Inline [
Date1, Date2
12/31/2024, 12/31/2023
12/31/2031, 12/31/2031
-, -
-, 31.12.2022
31.12.2025, -
12/31/2020, 12/31/2021
12/31/2019, 12/31/2020
2996, 3997
];

Now the requirement is if the date1 is before today it has to be 'N', today date and Future Dates it has to be 'A' and not relevant date or null it has to be 'Unknown', same applies for date2 as well.

I tried the below code and it is not working.

Testing_Load:
Load *,

if(isnull(date(date#(Date1))), 'Unknown', if(Date1< today(), 'N','A')) as Status1,
if(isnull(date(date#(Date2))), 'Unknown', if(Date2< today(), 'N','A')) as Status2,

Resident testing;

Drop Table testing;

Output:

date1date2Status1Status2
12/31/202412/31/2023AA
12/31/203112/31/2031AA
--UnknownUnknown
-31.12.2022UnknownUnknown
31.12.2025-UnknownUnknown
12/31/202012/31/2021NA
12/31/201912/31/2020NN
29963997UnknownUnknown

 

Expected Output:

date1date2Status1Status2
12/31/202412/31/2023AA
12/31/203112/31/2031AA
--UnknownUnknown
-31.12.2022UnknownA
31.12.2025-AUnknown
12/31/202012/31/2021NN
12/31/201912/31/2020NN
29963997UnknownUnknown

 

Regards,

V Shana

14 Replies
vikasshana
Creator II
Creator II
Author

Thanks for that @PrashantSangle , I will wait for your expression, in the mean while I will try to implement your suggestion in my main code.

vikasshana
Creator II
Creator II
Author

@PrashantSangle I tried the below if condition, can you review the same at your and check please. I tried it in my end and it seems to be working.

if(alt(date#(Date1,'YYYY/MM/DD'),
date#(Date1,'DD/MM/YYYY'),
date#(Date1,'MM.DD.YYYY'),
date#(Date1,'MM/DD/YYYY'),
date#(Date1,'DD-MM-YYYY'),
date#(Date1,'DD.MM.YYYY'),
'Unknown')='Unknown','Unknown',if(alt(date#(Date1,'YYYY/MM/DD'),
date#(Date2,'DD/MM/YYYY'),
date#(Date2,'MM.DD.YYYY'),
date#(Date2,'MM/DD/YYYY'),
date#(Date2,'DD-MM-YYYY'),
date#(Date2,'DD.MM.YYYY'))< today(),'N','A')) as Status1,
if(alt(date#(Date2,'YYYY/MM/DD'),
date#(Date2,'DD/MM/YYYY'),
date#(Date2,'MM.DD.YYYY'),
date#(Date2,'MM/DD/YYYY'),
date#(Date2,'DD-MM-YYYY'),
date#(Date2,'DD.MM.YYYY'),
'Unknown')='Unknown','Unknown',if(alt(date#(Date2,'YYYY/MM/DD'),
date#(Date2,'DD/MM/YYYY'),
date#(Date2,'MM.DD.YYYY'),
date#(Date2,'MM/DD/YYYY'),
date#(Date2,'DD-MM-YYYY'),
date#(Date2,'DD.MM.YYYY'))< today(),'N','A')) as Status2

PrashantSangle

Load
Date1,
Date2,
if(alt(date#(Date1,'YYYY/MM/DD'),
date#(Date1,'DD/MM/YYYY'),
date#(Date1,'MM.DD.YYYY'),
date#(Date1,'MM/DD/YYYY'),
date#(Date1,'DD-MM-YYYY'),
date#(Date1,'DD.MM.YYYY'),
'Unknown')='Unknown', 'Unknown',
if(alt(date#(Date1,'YYYY/MM/DD'),
date#(Date1,'DD/MM/YYYY'),
date#(Date1,'MM.DD.YYYY'),
date#(Date1,'MM/DD/YYYY'),
date#(Date1,'DD-MM-YYYY'),
date#(Date1,'DD.MM.YYYY'),
'Unknown')< today(), 'N','A')) as Status1,

if(alt(date#(Date2,'YYYY/MM/DD'),
date#(Date2,'DD/MM/YYYY'),
date#(Date2,'MM.DD.YYYY'),
date#(Date2,'MM/DD/YYYY'),
date#(Date2,'DD-MM-YYYY'),
date#(Date2,'DD.MM.YYYY'),
'Unknown')='Unknown', 'Unknown',
if(alt(date#(Date2,'YYYY/MM/DD'),
date#(Date2,'DD/MM/YYYY'),
date#(Date2,'MM.DD.YYYY'),
date#(Date2,'MM/DD/YYYY'),
date#(Date2,'DD-MM-YYYY'),
date#(Date2,'DD.MM.YYYY'),
'Unknown')< today(), 'N','A')) as Status2
Inline [
Date1, Date2
12/31/2024, 12/31/2023
12/31/2031, 12/31/2031
-, -
-, 31.12.2022
31.12.2025, -
12/31/2020, 12/31/2021
12/31/2019, 12/31/2020
2996, 3997
];

 

 

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
PrashantSangle

Yes you have to do in that way

 

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
vikasshana
Creator II
Creator II
Author

Got it, thank you @PrashantSangle