<div dir="ltr">Hi, <div>you are simply facing the SQL standard behavior of the | operator when it compares something to a NULL value, the whole result will be NULL. </div><div>In SQL, you can avoid that by wrapping each value in a "coalesce(myvalue, '')" that will replace NULL by an empty string. </div><div><br></div><div>In QGIS, you can also use the "+" operator, and this one does not sends a NULL like the pipe operator. Far more simple indeed, but less portable to pure SQL . </div><div>Cheers</div><div>Régis</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-12-21 3:33 GMT+01:00 damos <span dir="ltr"><<a href="mailto:damien.stephens@gmail.com" target="_blank">damien.stephens@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">HI I am trying to do a nested case statement for a labelling task.<br>
I have a list of mines of varying sizes with different commodities and would<br>
like to label with the name of the mine and the amount of each commodity at<br>
the mine in a new line below the name. I only want to label the mines that I<br>
have decided are signifcant and for this I have made a new column in my<br>
table called significant.<br>
My difficulty is that not all mines have the same commodities, for example<br>
one mine has copper (Cu) and no lead(Pb), while another has both. yet<br>
another will only have Pb.<br>
i can easily label all of the sigificant mines and their copper amoutns with<br>
a suffix of kt Cu using this code:<br>
<br>
case when  "signifcant"  = 'yes' then  title( "Name" ) ||   '\n'   ||   case<br>
when "Cu_e_t" <1 then '' else round("Cu_e_t"/1000,0) || 'Kt Cu' end else<br>
null end<br>
<br>
however if I then try to add in the Pb amounts like this;<br>
case when  "signifcant"  = 'yes' then  title( "Name" ) ||   '\n'   ||   case<br>
when "Cu_e_t" <1 then '' else round("Cu_e_t"/1000,0) || 'Kt Cu' end ||<br>
case when "Pb_e_t" <1 then '' else round("Pb_e_t"/1000,0) || 'Kt Pb' end<br>
else null end<br>
<br>
I lose all of the Cu only mines and only get labels for those with Cu and Pb<br>
or just Pb.<br>
I understand that I am doing something wrong with the nested case<br>
statements, but cant figure out what.<br>
<br>
any help would be much appreciated.<br>
int the mean time I am going back to do the formula in excel where I am<br>
capable.<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://osgeo-org.1560.x6.nabble.com/using-nested-case-statements-in-labelling-tp5300779.html" rel="noreferrer" target="_blank">http://osgeo-org.1560.x6.<wbr>nabble.com/using-nested-case-<wbr>statements-in-labelling-<wbr>tp5300779.html</a><br>
Sent from the Quantum GIS - User mailing list archive at Nabble.com.<br>
______________________________<wbr>_________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a><br>
List info: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">http://lists.osgeo.org/<wbr>mailman/listinfo/qgis-user</a><br>
Unsubscribe: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">http://lists.osgeo.org/<wbr>mailman/listinfo/qgis-user</a></blockquote></div><br></div>