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: 
pjpkumar26
Contributor III
Contributor III

Qlik Sense

Hi Team

I am using the following Date code 

where "Date">="Hire Date")
 
and I get the below output:
 
Date  ,             Hire Date
01-01-2022  05-01-2022
02-01-2022  05-01-2022
03-01-2022   05-01-2022
04-01-2022   05-01-2022
05-01-2022    05-01-2022
 
I need Hire Date as 01-01-2022 for date 01-01-2022 but form date 2 to 5    05-01-2022 which is coming fine
 
how can I make 01-01-2022 hire date to be 01-01-2022
 
Advance Thanks
Sudheer
Labels (2)
1 Reply
zar
Employee
Employee

Hi!

If I understand properly, you want to correct the wrong value of "Hire Date" 05-01-2022 for the Date 01-01-2022, and you want to convert it to 01-01-2022. 

Option A (If statement because only 1 error):

//Option A, IF statement
 
DATA:
Load
//take care of your date formats!
Date#([Date],'DD-MM-YYYY')as[Date]
    ,Date#([Hire Date],'DD-MM-YYYY') as [Hire Date]
    ,Date#([Corrected Hire Date],'DD-MM-YYYY') as [Corrected Hire Date]
;
Load
[Date]
    ,[Hire Date]
    ,If([Date]='01-01-2022' and [Hire Date]='05-01-2022', '01-01-2022', [Hire Date]) as [Corrected Hire Date]
;
Load * Inline [
Date, Hire Date
01-01-2022, 05-01-2022
02-01-2022, 05-01-2022
03-01-2022, 05-01-2022
04-01-2022, 05-01-2022
05-01-2022, 05-01-2022
];
 
Option B: mapping (more than one value to correct)
//Option B, mapping
Map_WrongDateToGoodDate:
Mapping
Load * Inline [
MapFrom, MapTo
01-01-2022|05-01-2022, 01-01-2022
]
;
 
DATA:
Load
//take care of your date formats!
Date#([Date],'DD-MM-YYYY')as[Date]
    ,Date#([Hire Date],'DD-MM-YYYY') as [Hire Date]
    ,Date#([Corrected Hire Date],'DD-MM-YYYY') as [Corrected Hire Date]
;
Load
[Date]
    ,[Hire Date]
    ,ApplyMap('Map_WrongDateToGoodDate',[Date]&'|'&[Hire Date], [Hire Date]) as [Corrected Hire Date]
;
Load * Inline [
Date, Hire Date
01-01-2022, 05-01-2022
02-01-2022, 05-01-2022
03-01-2022, 05-01-2022
04-01-2022, 05-01-2022
05-01-2022, 05-01-2022
];