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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
daez
Creator
Creator

Problem in tMap (datarange & conditions)

Hello dear community,

 

As a new talend open studio user, I'm struggling on a job, looking for some help.I have a XML file that i get from tHttpRequest; then a main row to textractXMLfield to formatdata.

Problem is, I have a field returning " 2018-02-20T22:00+0200/2018-03-31T23:59+0200 " which is a data range where a discount_price is active.

I need to consider that in my formatting & only show the discount_price if the current date is between this range, so i splitted it (with tExtractDelimitedFields) and get an input for my tMap which looks :

 

tLogRow (input)                                   tMap (out)                             tLogRow

ID                                                            ID

date_begin                                           discount_price

date_end

discount_price

 

Date_begin & Date end looks like : "yyyy-MM-dd".

I would like my out of tMap with ID of products and discount_price shown only if current date is between date_begin & date_end, otherwise empty field.

 

So I tried something like this to begin as a condition on the out :

 

(TalendDate.compareDate(TalendDate.getCurrentDate(),TalendDate.parseDate("yyyy-MM-dd",row7.date1)) == 1 && TalendDate.compareDate(TalendDate.getCurrentDate(),TalendDate.parseDate("yyyy-MM-dd",row7.date4)) == -1)? row7.Discount_price : " "

 

But infortunately; after 6 rows, errors : Caused by: java.text.ParseException: Unparseable date: "". My 7th rows has an empty date,  I have no idea how to check this condition, neither rewrite price only if the data is between range.

If someone could unlock me, would be very (very) appreciable.

 

Regards

 

 

 

Labels (4)
1 Solution

Accepted Solutions
manodwhb
Champion II
Champion II

@daez,can you try the below expresion. since some in 7th row you were getting empty values,so thats why it is not able to convert.

 

row7.date1 != "" && row7.date4 != "" ?((TalendDate.compareDate(TalendDate.getCurrentDate(),TalendDate.parseDate("yyyy-MM-dd",row7.date1)) == 1 && TalendDate.compareDate(TalendDate.getCurrentDate(),TalendDate.parseDate("yyyy-MM-dd",row7.date4)) == -1)? row7.Discount_price : " "):" "

View solution in original post

3 Replies
manodwhb
Champion II
Champion II

@daez,can you try the below expresion. since some in 7th row you were getting empty values,so thats why it is not able to convert.

 

row7.date1 != "" && row7.date4 != "" ?((TalendDate.compareDate(TalendDate.getCurrentDate(),TalendDate.parseDate("yyyy-MM-dd",row7.date1)) == 1 && TalendDate.compareDate(TalendDate.getCurrentDate(),TalendDate.parseDate("yyyy-MM-dd",row7.date4)) == -1)? row7.Discount_price : " "):" "

Anonymous
Not applicable

You'll need an empty string  / null check when you parse those variables . I typically add a few temp vars to the tMap in the middle column to accomplish this. see my example below0683p000009Lx6O.png

 

 

 

daez
Creator
Creator
Author

@manodwhb Thank you so much. It works. I was working and forgot to instant check forum. I had issue on the first condition, checking if both were null. 

 

Thanks again, what a relief when you F6 and it works !