How would/could I use the select by expression tool to select only the first row for each origin_id group? The rows with a yellow border are the ones I want selected.

example selection

1 Answer 1


You can use:

array_first(array_agg($id,"origin_id",order_by:=$id)) = $id

You did not specify the sorting of your table so I assume you use the default order by feature id ($id). If you use another sorting, change the order_by:= part to a field you wish to sort by. For example to sort by destination_id:

array_first(array_agg($id,"origin_id",order_by:="destination_id")) = $id

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.