Zet - How do I add labels over new lines in QGIS?

How do I add labels over new lines in QGIS?

1. Adding a New Line in Labels:

To add a new line in labels, use the \n character for line breaks:

"field1" || '\n' || "field2"

2. Handling NULL Values in Labels (with Concatenation):

When concatenating fields, if one of the fields may contain NULL, use the coalesce() function to provide a fallback value:

"field1" || '\n' || coalesce("field2", '')
  • This prevents the entire label from becoming NULL when one field is NULL.

3. Using LIKE for String Matching in Filters:

Use the LIKE operator for pattern matching. % is the wildcard for any sequence of characters:

"field_name" LIKE '%pattern%'
  • Use ILIKE for case-insensitive matches:
"field_name" ILIKE '%pattern%'

#qgis