Question: 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](https://i.stack.imgur.com/7jVDI.png)](https://i.stack.imgur.com/7jVDI.png)

Answer: 
You can use the tool "Statistics by categories" (in the processing toolbox in QGIS 3.2)

[![enter image description here](https://i.stack.imgur.com/3Iazd.jpg)](https://i.stack.imgur.com/3Iazd.jpg)

[![enter image description here](https://i.stack.imgur.com/2MDpX.jpg)](https://i.stack.imgur.com/2MDpX.jpg)

[![enter image description here](https://i.stack.imgur.com/ggyQe.jpg)](https://i.stack.imgur.com/ggyQe.jpg)
Create a new column and fill it with a `case when` or `if` clause looping over all possible values. Assign each combination a different letter of the alphabet, and then do a statistical analysis of the new column.

Or just load it into a database.