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

1 Answer 1

4

You could try rule based labeling:

enter image description here

4
  • Thank you i already tried that, did not work for me. Sep 27, 2020 at 18:20
  • What do you mean by did not work
    – BERA
    Sep 28, 2020 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, 2020 at 6:04
  • No specific reason, I can upgrade to LTR 3.10 Sep 28, 2020 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.