[GIS] Controlling Map Tips in QGIS

maptipsoverlapping-featuresqgis

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.

Best Answer

@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,

Related Question