I'm trying to get the maximum value from an array, using the max()
function. The syntax for the max()
function is this:
max(value1,value2…)
I have an array: [ 1, 2, 3, 4, 5, 6, 7, 8 ]
which I got by using this expression:
array_remove_all( array_agg( "fieldname"), maximum("fieldname"))
I need to obtain the maximum value from the array, but the max()
function doesn't work. When I calculate the max() of the array, it gives this error:
Eval Error: Cannot convert '' to double
I can convert the array to a string using the array_to_string()
function. When I calculate the max of the string version of the array, it gives this error:
Eval Error: Cannot convert '1,2,3,4,5,6,7,8' to double
So it seems the max()
function can't accept an array or a list in string format as input. I also tried the maximum()
function, with similar lack of results. I don't see any other function in the Field Calculator for finding the maximum value
How to extract the maximum value from an array in the Field Calculator?