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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] Date is not supported in the if else condition

Hi,
I have input excel(row1) with dates in the format "mm/dd/yyyy" and i have mapped the date in tmap expression builder using the if else condition. In the output the the calculated double value should be the result.
Input excel Format:
Date              Condition
08/09/2015          Y
10/09/2015          N
In tmap expression builder, i have given the condition as below,
row1.Condition.equals("Y")? ((TalendDate.diffDate(row1.Date, TalendDate.getCurrentDate(), "dd") < 365 ) ? 0.20 : 0.5):0.0
In the above if condition, the row1.Date is not taking the value from the input excel sheet.
Getting the below error as,
Exception in thread "main" java.lang.Error: Unresolved compilation problem: 

Exception in component tMap_1
java.lang.NullPointerException
My requirement is to find the difference between the date from the input excel and current date and if its less than 365 days then reture value 0.20 otherwise 0.5. If the condition not satisfies then should return value 0.
Please help me to correct this one. Or suggest me anyother alternative way to call the date from input excel.
Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi
Read Date column from excel file with Date type, and set its pattern as "MM/dd/yyyy" rather than  "mm/dd/yyyy" on the schema. 
Exception in component tMap_1
java.lang.NullPointerException

Please check if there exist null value in Condition column, if so, you need to handle the null value before using the expression like:
row1.Condition.equals("Y")


Best regards
Shong

View solution in original post

2 Replies
Anonymous
Not applicable
Author

Hi
Read Date column from excel file with Date type, and set its pattern as "MM/dd/yyyy" rather than  "mm/dd/yyyy" on the schema. 
Exception in component tMap_1
java.lang.NullPointerException

Please check if there exist null value in Condition column, if so, you need to handle the null value before using the expression like:
row1.Condition.equals("Y")


Best regards
Shong
Anonymous
Not applicable
Author

This works fine. Thank you