Another graphical, dynamic and most importantly simple way to detect duplicate attributes: use QGIS's expression builder.
Highlight duplicates in attribute table:
Suppose FieldWithDuplicates
is the attribute containing duplicates ( TreeID
in the screenshot below).
Enable Conditional Formatting (see red arrow below) with the following condition:
count(1,"FieldWithDuplicates") > 1
To group all duplicates at the top, right click the column, select Sort
Enter the above expression without the >1
, and deselect Sort ascending.
Highlight features with duplicate attributes on canvas:
You could add a new symbol or label with the filter set to the above condition.
And of course you can enable a data derived override based on the the same.
For example, if you want to highlight labels for features with a duplicate attribute, you can set it to draw a label background with the following override:
count(1,"FieldWithDuplicates") > 1
to achieve something like the following
In both situations, of course, once you either delete or change the duplicate attributes, the formatting/styling updates instantly.