At 3.24.3, I need to create a list of the unique values in field A, grouped by field B.

In my example, a data table contains a series of inspection dates (field A) that occurred across several districts (field B). I need a single output table that contains the unique inspection dates for each district.

My (unwieldly) workaround is to select those records in the first district, then apply the List Unique Values tool on that selected set. I then repeat for each subsequent district. Unfortunately, this creates a separate output table for each district.

How can I create a single output table that contains the unique dates found in each district?


Here is an example of my original data, with the duplicate records highlighted:

enter image description here

And here is the desired list of unique inspection_date values, grouped by the field district

enter image description here

  • 2
    Can you please show a visual example of what you are trying to implement?
    – Taras
    Jun 27 at 6:45

2 Answers 2


Use a virtual layer:

select "district", "thedatefield"
from yourtable
group by "district", "thedatefield"
  • Using DISTINCT can also help
    – Taras
    Jun 27 at 9:18
  • 1
    BERA's answer worked perfectly, and it had the added benefit of being my first foray into virtual layers. For clarity, I edited the answer by adding the double quotes surrounding each field name.
    – Stu Smith
    Jun 27 at 20:20

I just discovered an alternate way to solve my question by using the Delete Duplicates by Attribute tool. Simply select both the inspection date and district fields in the Field to match duplicates by section. Voila! The output exactly matches the table generated by BERA's answer.

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.