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: 
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.
I would use the field calculator to create a virtual field containing the concatenation (i.e. combination) of your two fields, like this:

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

The underscore `'_'` ist just for better readabilty and does not affect the result.

Then use the 'Show statistical summary' button (the button with the big *sigma*):

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

Herein select your layer and the virtual field you just created, and under **Count (distinct)** you will find the count of your columns combinations:

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

The virtual field and the tool do dynamically refresh when data changes.