I'm attempting to make QGIS maptips display a hyperlink as the text from another field in the attribute table. Below are 3 attempts of HTML and the different results.

When "title documents" is not NULL

enter image description here

When "title documents" is NULL

enter image description here


[%case when "title documents" is not NULL then '<a href='||"title documents"||'>' end %]
[%case when "title documents" is not NULL then ' "title no" </a>' else 'Not available' end %]


<a href=[%CASE WHEN "title documents" is not null then "title documents"%] > [%"title no"%]</a>
[%CASE WHEN  "title documents" is null then 'Not Available' END%]


[%case when "title documents" is not '' then '<a href='||"title documents"||'>' else '' end %]
[%case when "title documents" is not NULL then 'Click Me</a>' else 'Not available' end %]

I'm trying to get result 3 but rather than 'Click Me', make it display "title no" which I would have thought code line 1 would achieve but obviously not.


You have to insert only one QGIS Expression under [% %] brackets and play with the ELSE clause from CASE.

Try the following layer maptips expression :

  WHEN "title documents" IS NOT NULL
    THEN '<a href="' || "title documents" || '">' || "title no" || '</a>'
  ELSE 'Not available'
END %]

Explanation :

Case statement :

  WHEN condition_1 THEN result_1
  WHEN condition_2 THEN result_2
  [ ELSE result_else ]

The only one condition I set is when the field "title documents" IS NOT NULL then display "title no" value as a text for a html link with "title documents" value as link.

Else, (if "title documents" IS NULL) display the text Not available.


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.