Is there a way to summarize string attributes using QGIS 3.0 without having to export to excel?

I have a point layer as an output of a spatial join. I would like to summarize the information so that it looks more like the "desired output" below using QGIS 3.0. (I recreated what I wanted out of QGIS for demonstrative purposes of what I am trying to do I'm QGIS).

I have tried multipart to singlepart (assume since points this does not work).

Tried the "list unique values tool" and either I don't know how to work the tool, or that is DEFINITELY not the answer.

enter image description here

  • So does this mean my question is not possible inside of QGIS? That alone is an answer. Apr 10, 2018 at 11:33
  • have a look at virtual layer (if you search GIS SE you'll find SQL query that do what you want)
    – J.R
    Apr 13, 2020 at 17:17

2 Answers 2


You will need to create a new field with the combination of the two attributes that you want to be a unique row, for a later dissolve by that attribute.

If "ID1" and "ID2" are string fields, you can concatenate them (if they are numbers, you can convert them to string and concatenate in the same expression).

  • Create a new string type field (name it, i.e., ID1_ID2) and populate it with the expression: concat( "ID1", '_', "ID2") in the Field Calculator.

Each row of the table is a feature of the layer, if they are points returned by a spatial join, it is supposed that all features with the same "ID1" value are identical points. When you dissolve features, if they are spatially disjointed, they will be a multipart feature with more than one part; but if they are identical features they will have just one part (one point in this case).

  • Dissolve the layer, by the field "ID1_ID2".

The output is a new layer, with one feature for each distinct combination of "ID1" and "ID2".


For me your question is unclear. You say summarize but all you do is delete duplicates. You are missing the column with values to sum?

In any case you can use python pandas library:

import pandas as pd #Not sure pandas is included in QGIS3. If not it is worth installing
layer = iface.activeLayer()

fields_of_intrest = ['ID1','ID2','valuefield']
datagen = ([g[fval] for fval in fields_of_intrest] for g in layer.getFeatures())

df = pd.DataFrame.from_records(data=datagen, columns=fields_of_intrest)
df2 = df.drop_duplicates(subset=fields_of_intrest[:-1]) #Just drop duplicate ID1 and ID2

df3 = df.groupby(fields_of_intrest[:-1]).sum() #Sum valuefield per ID1-ID2 combination

df3.to_clipboard() #Paste into excel or whatever

enter image description here

Your Answer

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

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