Categories from register codes — Recipe (QGIS)

Tool-bound implementation of the Categories from register codes (Task) Task Schema in QGIS 4.2. Worked example: Dwelling size by construction period in Copenhagen (Example).

Data you need

RoleFormLevel of measurementNotes
Register unitspoints or a tablecode fields: nominal; years and areas: ratioe.g. dwellings with use codes, construction years, rental codes
Code listsdocumentation—the register’s own definitions of each code
Units with categories (output)the same layernominal category, or a 0/1 indicator

Read and count the codes (Task Schema steps 2–3)

Read the code list for each field you consider. Then count the units per code: Processing Toolbox › Vector analysis › Statistics by categories, Field(s) with categories the code field, no value field. Note the empty values.

Decide and select (steps 4–5)

Write the decisions down first: which codes form the population, and which codes go into which category. Then Extract by expression (Tool - QGIS) for the population, e.g.

"<code field>" IN (<codes>) AND "<year field>" < <year>

Write the category (step 6)

Field calculator (Tool - QGIS), a text field:

CASE WHEN <condition 1> THEN '<category 1>'
     WHEN <condition 2> THEN '<category 2>'
     ELSE NULL END

or an integer 0/1 indicator: if(<condition>, 1, 0).

Check (step 7)

Count again per category (Statistics by categories on the new field): every unit should be in exactly one category, or left out on purpose.

Checked in QGIS 4.2.2, October 2026.