Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I am looking to get max of two column values as below. I have tried tjavarow and used the below syntax but it is throwing a null pointer exception. Any help will be appreciated.
output_row.MAX = Math.max(input_row.Col1,input_row.Col2);
<Col1> | <Col2> |
19.25 | |
8.85 | |
12.43 | |
17.36 | |
17.36 | |
8.85 | |
11.97 | 10.35 |
11 |
Sorry it should be like this ( 3rd condition should be 1st)
input_row.Col2 == null && input_row.Col1 == null ? 0 :
input_row.Col1 == null ? input_row.Col2 :
input_row.Col2 == null ? input_row.Col1 :
input_row.Col1 >= input_row.Col2 ? input_row.Col1 : input_row.Col2
input_row.Col1 >= input_row.Col2 ? input_row.Col1 : input_row.Col2
Hi Abhilash Kumar,
I have tried this and I am still getting NullPointerException. any other work around ?
you could simply add null checks
input_row.Col1 == null ? input_row.Col2 :
input_row.Col2 == null ? input_row.Col1 :
input_row.Col2 == null && input_row.Col1 == null ? 0 :
input_row.Col1 >= input_row.Col2 ? input_row.Col1 : input_row.Col2
Sorry it should be like this ( 3rd condition should be 1st)
input_row.Col2 == null && input_row.Col1 == null ? 0 :
input_row.Col1 == null ? input_row.Col2 :
input_row.Col2 == null ? input_row.Col1 :
input_row.Col1 >= input_row.Col2 ? input_row.Col1 : input_row.Col2
Thank you so much Abhishek. It has worked.