[GIS] Count of the different combination of two attributes in QGIS

countcross-tabulationfield-calculatorqgis

I've been trying in vain to use the field calculator in QGIS 2.8 to count the combinations of two attributes in two separate columns.

First column is called "Alds_klass" and second is called "bygn_klass". I want to count the different combinations of the two columns, not the sum, but the number of each combination.

enter image description here

Best Answer

If you're ready NOT to use the field calculator i would create a virtual layer based on the following query (to adapt) :

select count(*) as tot, col_a, col_b from my_table
group by col_a, col_b
order by tot desc

Which would be "dynamic" ...

(implies to use a newer QGIS version...)

Related Question