I'm relatively new to QGIS (2.14.7 on Windows), and trying to learn how to set Map Tips.

Problem is, many points of my point Shapefile are located at exactly same place (overlapping). Can't be sure but it seems Map Tips picks up the feature of first row found in the attribute table in such a case. However I would like to display the last feature, if at all possible.

The image below is a fake example of attribute table (LHS), of which all three features are at the same location.

attribute table and map tips A house (House A) had three owners (Emi, Jon, and Sam) who were recorded in chronological order. I wish to display Sam (the most recent owner) by the Map Tips, but I see Emi instead (RHS).

Setting of HTML field is:

<b>[% "house" %]</b><br>
[% "owner" %]<br>
[% "start_y" %] - [% "end_y" %]

Is there any how-to to control what Map Tips shows? (If this question is too broad, then specifically, to choose last record?)

My apologies, but I have some constraints in my working environment, which complicate things:

  • I am not allowed to modify the order of this Shapefile for various reason. (I thought ogr2ogr can sort it by year in descending order.)
  • Nor remove duplicated features.
  • The most recent owner may not mean they are current. It makes filtering (by "end_y" for instance) or applying Expression too difficult... for me.

2 Answers 2


@Matthias Kuhn: Following your answer, this image shows my first Virtual Layer to control order of attribute table, with ultimate goal of controlled Map Tips.

enter image description here

  1. Layer | Add Layer | Add Virtual Layer
  2. [Import] and select existing layer (in my case "household" which corresponds to "household.shp")
  3. In [Query] window, typed in SELECT * FROM household ORDER BY end_y DESC
  4. This gave me a virtual layer in descending order.
  5. Copied Style from "household" layer (which already has HTML styling in Properties | Display)
  6. Yes, now I can see Sam on Map Tips!

Thank you again. An SQL query, came from my memo while trying to learn ogr2ogr, worked for whatever reason. But I am sure you had opened my eyes to SQL world.

All the Best,

  • And please feel free to remove the initial excuse line, I think the future visitor is much more interested in the actual content ;) Commented Oct 24, 2016 at 13:33

You could use a virtual layer. With this you can sort and filter the rows without altering the original dataset and tweak it for visualisation.

With newer versions of QGIS you could possibly also use aggregate expressions.

These are just hints to get you started. Please post a more complete answer based on these hints so future readers can learn from it as well.

  • Thank you so much Matthias Kuhn! I have never used SQL before, so it sounded scary at first. But it works like charm.
    – Kazuhito
    Commented Oct 23, 2016 at 10:08

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.