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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Date calculation

Hello Community,

 

I want to produce an etl process for sales. I have Input asc file with Informations, one of them must be calculated. In Pentaho we had used the Calculator for it, I think in Talend Studio the right transformer is tjavarow. In the asc. file date is in this form (string) 19990816. With this Information I want to calculate quarter, month and year. After this procedure I Need a combination lookup and at last the Information should be written in an Oracle table. Is all them possible in Talend Studio. I'm trying since days and reading in different Forums, but don't find any Option.

Thank you.

Labels (4)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi
In Talend, call the built-in functions on tJavaRow or tMap to calculate the parts of year, for example:
tfileInputDeliimited--row1--tMap1--out1--tMap2--out2--tMap3----
                                                                                           |
                                                                                         lookup
                                                                                            |
                                                                                       tOracleInput
on tMap1: parse the string to a Date with built-in function TalendDate.parseDate("yyyyMMdd", row1.dateColumn)

on tMap2: get parts of year
quarter: TalendDate.getPartOfDate("MONTH", out1.dateColumn)/3+1
month: TalendDate.getPartOfDate("MONTH", out1.dateColumn)
year: TalendDate.getPartOfDate("YEAR", out1.dateColumn)

Regards
Shong

View solution in original post

24 Replies
Anonymous
Not applicable
Author

Hi
In Talend, call the built-in functions on tJavaRow or tMap to calculate the parts of year, for example:
tfileInputDeliimited--row1--tMap1--out1--tMap2--out2--tMap3----
                                                                                           |
                                                                                         lookup
                                                                                            |
                                                                                       tOracleInput
on tMap1: parse the string to a Date with built-in function TalendDate.parseDate("yyyyMMdd", row1.dateColumn)

on tMap2: get parts of year
quarter: TalendDate.getPartOfDate("MONTH", out1.dateColumn)/3+1
month: TalendDate.getPartOfDate("MONTH", out1.dateColumn)
year: TalendDate.getPartOfDate("YEAR", out1.dateColumn)

Regards
Shong

Anonymous
Not applicable
Author

Hello Shong,

 

you mean that is possible even though I have two different tables in my database? I have in Pentaho a calculator in which I have calculated the quarter, month and year The key for is is from table2 my primary key (salesdate). I make a combine lookup to merge the values generated from table1 (date) (primary key is technical_key) with table2 (sales) (Primary key ist salesdate). The last step ist writing the information in table2 (sales). 

tmap is enogh for all of this?

thank you for your rapidly answer,

best regards,

 

Seher

Anonymous
Not applicable
Author

Hello
Yes, tMap can be used do many types of transformation and used to do joins between different data flows, below are two KB articles tMap basic usage. I think it must be helpful for you to learn and understand how tMap works.
https://help.talend.com/pages/viewpage.action?pageId=190513444
https://help.talend.com/pages/viewpage.action?pageId=190513450

Hope it helps.

Regards
Shong
Anonymous
Not applicable
Author

Thank you, I will read it and hope it will be easy to make the calculation. But I need tOracleTableOutput and not Input or didn't I read the tooltips false. I want to write the information back to my Table in Database. Thank you very much.

Anonymous
Not applicable
Author

Sorry, I understand now, why it should be Input. 

Anonymous
Not applicable
Author

Sorry I have another question because of this, my java debugger doesn't start so I can't look myself

I have added 

TfileInputDelimited (Sales.csv) - row1 - tMap1 - out1 - tMap2 - out2 - tLogRow1

                                                                                         I

                                                                                         I row2(lookup)

                                                                                       TOracleInput1

I think my OracleInput1 is my Date Table and I want make a lookup between them.

In tMap1 I have this TalendDate.parseDate("yyyyMMdd", row1.Bestellnummer)  and it doesn't fail. 

I have in row2 of tMap2 the expression for quarter, month and year, you have written in your message. In tMap2 I get this error Job compile errors
At least job "Umsatz_test" has a compile errors, please fix and export again.
Error Line: 1720
Detail Message: Type mismatch: cannot convert from int to String
There may be some other errors caused by JVM compatibility. Make sure your JVM setup is similar to the studio.. 

 

How can I fix it without a debugger?

cterenzi
Specialist
Specialist

Verify the schema data types of the columns containing the quarter, month and year expressions in your tMap2.

Anonymous
Not applicable
Author

Hello cterenzi,

I've add after every step a tLog and could see the output. It was easier to fix. Thanks for your help. 

Anonymous
Not applicable
Author

But I can't control the lookup step, if everything is set right to accept your solution. I have add ojdbc in lib and web-inf and get this (Detail Message: oracle.jdbc cannot be resolved to a type
There may be some other errors caused by JVM compatibility. Make sure your JVM setup is similar to the studio.) on tOracleInput
The version of jdbc is 6 and I have tried everything in the Community.