Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Calculation of a value based on two values

Dear All

 

I'm new to Talend and I'm trying to learn it know. I already saw most of the available videos and I have to say that's an amazing tool.

 

So let's go to the topic. I need to calculate a value based on two columns from a excel file. I have the Starting Kms  and       the arriving Kms and with the collection of the data I wont to have a column with the difference between this 2 values.

 

This way I will have the traveled Kms by a car or person.

 

Is this possible to do in Talend? if Yes how can I do it? Is it inside Tmap?

 

Thanks in advance

 

Nelson Parreira

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

This is very easy to do. Lets assume your starting and ending values are in columns A and B in your Excel spreadsheet. You configure your tFileInputExcel component so that you are bringing in columns A and B. This is described in the documentation for the component. Once you have done this, add a tMap component. In this component you can set the output "table" to have 3 columns (A, B and C). You may your input column A to the output column A, B to B and in the output of C you would have some code looking something like this....

 

row1.B!=null && row1.A!=null ? row1.B - row1.A : 0

The above will first check that the values of A and B are not null. It then subtracts A from B. If either of the values are null, it will return 0.

View solution in original post

2 Replies
Anonymous
Not applicable
Author

This is very easy to do. Lets assume your starting and ending values are in columns A and B in your Excel spreadsheet. You configure your tFileInputExcel component so that you are bringing in columns A and B. This is described in the documentation for the component. Once you have done this, add a tMap component. In this component you can set the output "table" to have 3 columns (A, B and C). You may your input column A to the output column A, B to B and in the output of C you would have some code looking something like this....

 

row1.B!=null && row1.A!=null ? row1.B - row1.A : 0

The above will first check that the values of A and B are not null. It then subtracts A from B. If either of the values are null, it will return 0.

Anonymous
Not applicable
Author

Great rhall_2_0

 

It was exactly what I was looking for. 0683p000009MACn.png