how to get the max value out of 6 fields from row in excel file

One Star

how to get the max value out of 6 fields from row in excel file

Hallo,
I have an excel file that contains 5000 rows with data about customers and each row contains the turnover from six years for each customer now I want to get the highest turnover out of this six years for each customer.
Which component should I use and how do I get the max?
Greetings
One Star

Re: how to get the max value out of 6 fields from row in excel file

I use tFileInputExcel -> tMap to filter not needed values and from tMap -> tJavaRow -> tMap to splitt the result to different files.
I think with tJavaRow I could get the max value out of the six columns and fill a new column (maxValue)
I`m not a Java Junky so hope someone can help me get the right code, I found this:
double[] myArray={field1, field2, field3, field4, field5, field6};
double max;
max = myArray;
for (int i =1; i < myArray.length; i++)
{
if (myArray > max)
max = myArray;
}
row1.maxValue=max;
Is this a simple way or is there another solution in Talend?
Four Stars

Re: how to get the max value out of 6 fields from row in excel file

Hi Loki,
Use tMemorizeRow component, which will solve your problem of comparing data, but you need to tweak the java code based on normal if-then-else logic. Please see the forum post with requirement to compare columns.
http://www.talendforge.org/forum/viewtopic.php?id=35034
Hope it helps.
Thanks
Vaibhav