Finding the Max value amongst a set of columns

One Star

Finding the Max value amongst a set of columns

Hi All,
I have a set of integer columns from my source and i would need to find the max value amongst this set of columns.
Eg:
something like GREATEST(col1,col2,col3,col4...).... the column having this expression should return the maximum value amongst the set of columns in expression.
Please let me know if any such function is available in Talend. I am using 'Talend Open Studio for Data Integration -- Ver5.4'

Thank You
Regards
Sudharshan
Seventeen Stars

Re: Finding the Max value amongst a set of columns

hi,
use tAggregateRow and the max function for that.
https://help.talend.com/search/all?query=tAggregateRow&content-lang=en
regards
laurent
One Star

Re: Finding the Max value amongst a set of columns

Hi Kzone,
Thanks for the quick response, but i would need to fine the max value amongst a set of columns, and not the max value of the values in a column.
Let the input be of the below format
----+--------+-------+------+
id |col1 | col2 | col3 |
----+--------+-------+------+
A1 |15 |14 |13 |
----+--------+-------+------+
A2 |14 |4 |56 |
----+--------+-------+------+
A3 |11 |24 |16 |
----+--------+-------+------+
the output should be
----+--------+
id |Max |
----+--------+
A1 |15 |
----+--------+
A2 |56 |
----+--------+
A3 |24 |
----+--------+
i guess the output with tAggregateRow with Max will make

----+--------+-------+------+
id |col1 | col2 | col3 |
----+--------+-------+------+
A1 |15 |24 |56 |
----+--------+-------+------+
A2 |15 |24 |56 |
----+--------+-------+------+
A3 |15 |24 |56 |
----+--------+-------+------+
Please correct me if i am wrong.
Thank You
Regards
Sudharshan
Seventeen Stars

Re: Finding the Max value amongst a set of columns

oh ... sorry
read too fast your request .
look at a solution as soon as I 've got some "free time" Smiley Wink
regards
laurent
One Star

Re: Finding the Max value amongst a set of columns

Hi ,
Thanks..For now i have used a tJavaRow component to get the max value among the set of columns and set it to an output column.
Solution was something as below...
The set of columns(Col1...Col6) from tMap is made to pass through a tJavaRow
Code in tJavaRow
---------------------
int[] myArray ={input_row.Col1,input_row.Col2,input_row.Col3,input_row.Col4,input_row.Col5,input_row.Col6};
int max;
max = myArray;
for (int i = 1; i < 5; i++)
{
if (myArray > max)
max = myArray;
}
output_row.MaxValue=max;//This sets the max value to an output column where output_row.MaxValue is the output column.
Kindly let me know if there is any other simpler way of doing this.
Thank You
Regards
Sudharshan