5

I'm looking for a way to find the max number of four different fields and write that in a new column. I have managed to use the field calculator to "+" the different fields into a new, but when I'm trying the max command I get lost. some of the fields are empty.

I have written this statement:

max( 
(CASE WHEN  "mean" IS NOT NULL THEN "mean" ELSE 0 END),
(CASE WHEN  "_mean" IS NOT NULL THEN "_mean" ELSE 0 END),
(CASE WHEN  "mean_1" IS NOT NULL THEN "mean_1" ELSE 0 END),
(CASE WHEN  "max" IS NOT NULL THEN "max" ELSE 0 END),
)

enter image description here

  • 2
    Your statement is failing because you have an extra comma after your last CASE. – ArMoraer Dec 8 '16 at 14:41
7

You could try using this expression instead:

max( 
coalesce("mean", 0), 
coalesce("_mean", 0), 
coalesce("mean_1", 0), 
coalesce("max", 0) 
)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.