[Qgis-user] New Labeling: conditional labels

Giuseppe Sucameli sucameli at faunalia.it
Wed Dec 28 11:01:43 PST 2011


Hi Andreas,

On Thu, Dec 22, 2011 at 2:31 PM, Andreas Neumann <a.neumann at carto.net> wrote:
> What I want is that a label is only drawn if a column value is larger than
> 0. I don't want to label features with a value of zero.
>
> Do you have any hints how the syntax works for such a case? I see ">"
> operators but no "if" or "when".

there's no "if" operator, but ">" returns 1 if true and 0 if false,
e.g. (field > 5)*10 let's give you 10 or 0 as result.

The problem is that you don't want to display anything when
the field value is 0, so we can use the substr function.

Here's the solution to your problem:
substr(id, 0, (id > 0)*-1)
that means if id <= 0 then substr(id, 0, 0) else substr(id, 0, -1)

In general:
substr(output, 0, (condition)*-1)

Cheers.

> If it is not possible, then I can still do it in Postgis, but it would be
> nice being able to do this in QGIS.
>
> Thanks for any hints,
> Andreas
>
> --
> --
> Andreas Neumann
> Böschacherstrasse 10A
> 8624 Grüt (Gossau ZH)
> Switzerland
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user



-- 
Giuseppe Sucameli



More information about the Qgis-user mailing list