[Qgis-user] using nested case statements in labelling

damos damien.stephens at gmail.com
Tue Dec 20 18:33:53 PST 2016


HI I am trying to do a nested case statement for a labelling task.
I have a list of mines of varying sizes with different commodities and would
like to label with the name of the mine and the amount of each commodity at
the mine in a new line below the name. I only want to label the mines that I
have decided are signifcant and for this I have made a new column in my
table called significant.
My difficulty is that not all mines have the same commodities, for example
one mine has copper (Cu) and no lead(Pb), while another has both. yet
another will only have Pb.
i can easily label all of the sigificant mines and their copper amoutns with
a suffix of kt Cu using this code:

case when  "signifcant"  = 'yes' then  title( "Name" ) ||   '\n'   ||   case
when "Cu_e_t" <1 then '' else round("Cu_e_t"/1000,0) || 'Kt Cu' end else
null end

however if I then try to add in the Pb amounts like this;
case when  "signifcant"  = 'yes' then  title( "Name" ) ||   '\n'   ||   case
when "Cu_e_t" <1 then '' else round("Cu_e_t"/1000,0) || 'Kt Cu' end ||  
case when "Pb_e_t" <1 then '' else round("Pb_e_t"/1000,0) || 'Kt Pb' end
else null end

I lose all of the Cu only mines and only get labels for those with Cu and Pb 
or just Pb.
I understand that I am doing something wrong with the nested case
statements, but cant figure out what.

any help would be much appreciated.
int the mean time I am going back to do the formula in excel where I am
capable.




--
View this message in context: http://osgeo-org.1560.x6.nabble.com/using-nested-case-statements-in-labelling-tp5300779.html
Sent from the Quantum GIS - User mailing list archive at Nabble.com.



More information about the Qgis-user mailing list