4

I have values which are from 0 - 21000. Now i want to display only the values above 10 and the number 21000 should be displayed as 2,1%. I want to use the data defined properties. My first assumption was:

"values">10
CASE 
WHEN "values"=21000 THEN 2,1%
ELSE "values"
END

This does not work though because i just can´t click OK in the data-defined properties. The Error says:

syntax error, unexpected CASE, expecting $end.

Is there anything else to consider?

1

Try something like this (presuming it is for labelling) with an expression:

CASE
WHEN "values">10 AND "values"<>21000 THEN "values"
WHEN "values"=21000 THEN '2.1%'
END  

You can also use a rule-based labelling, with:

"values">10

And as a label:

CASE
WHEN "values"=21000 THEN '2.1%'
ELSE "values"
END  

enter image description here

Cheers,

  • 1
    I can click ok now and everything above 10 is displayed, which is fine, but the 21000 is still not displayed as 2,1%. Any advise? Thanks! – Philipp Dec 2 '16 at 10:07
  • Are you sure you've used the exact formulas? It's working on my qgis 2.18.1... How about the second method? – Victor Dec 2 '16 at 10:15
  • The inverted commas around the 2.1% are important. '2.1%' – Victor Dec 2 '16 at 10:19
  • Somehow it still does not show the 21000 as 2.1%. I can´t tell you why and i´ve done everything like you told me. Even as rule based labelling it won´t work. I thank you very much for taking your time! – Philipp Dec 2 '16 at 10:37
  • Maybe try with inverted commas for all values: '10' and '21000'. If you pass me a subset or your data I will have a look. – Victor Dec 2 '16 at 10:48

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.