I have a shapefile with points that are joined to the closest twenty points from another shapefile. The joined shapefile has columns from the original shapefile: name (ID), elevation (Z), name from joined shapefile (name) and elevation from the joined shapefile (Z2).
So twenty rows have the same ID and name but differing Z and Z2. I would like to use the field calculator to return the row that has the smallest absolute difference between Z and Z2 with the matching ID and name.
Using a case statement in the qgis field calculator I can get all the results to return the difference in a new column:
CASE WHEN "Name" = "ID" THEN abs("Z" - "Z2") END but I would like only the smallest value to return.
minimumexpression