0

I'm trying to use an expression to label a layer by using multiple fields, and assign different colors using QGIS 2.16.

In ArcGIS I am able to achieve this using the following expression:

def FindLabel([DesceasedName], [ownerName], [all_spaceid]):  
  
  if [DesceasedName] = "":  
    return "<BOL><FNT size = '5'>" + [DesceasedName] + "</FNT></BOL>"+   '\n' + "<CLR red='115' green='38' blue='0'><BOL>" + [all_spaceid] + "</BOL></CLR>" 
  elif [DesceasedName] == "":  
    return "<CLR blue='255'><FNT size = '5'>" + [ownerName] + "</FNT></CLR>"  + '\n' + "<CLR red='115' green='38' blue='0'><BOL>" + [all_spaceid] + "</BOL></CLR>"
  else:  
    return ""

How to achieve the same labeling in QGIS?

0
4

You could try rule based labeling:

enter image description here

4
  • Thank you i already tried that, did not work for me. – user2722043 Sep 27 '20 at 18:20
  • What do you mean by did not work – BERA Sep 28 '20 at 5:47
  • 1
    do you have a specific reason to use QGIS 2.16? Any chance to install a newer version? 3.10 or 3.14? – sn1ks Sep 28 '20 at 6:04
  • No specific reason, I can upgrade to LTR 3.10 – user2722043 Sep 28 '20 at 10:33

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.