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: 
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...)
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)