Export column naming
How Fieldbase builds column names in the export. The convention is mechanical — same input, same output, every time — so you can predict the column from the YAML alone.
Core rules
Every export column name is built mechanically from the question id and the position inside the question. The rules don’t change between question types, so once you know them you can predict every column without running the survey.
qid— the question id you wrote in the YAML. It must match the validity rule (see Glossary → qid).- Position prefixes —
rfor row,cfor column,ofor option. Written inline, no separator. - Loop suffix —
_Nis appended for questions that live inside a loop, whereNis the iteration number. See Loop suffixes.
Pattern by question type
| Question type | Pattern | Example |
|---|---|---|
single, open, number | qid | QBrand |
multi (one column per option) | qidoN | QFeatureso1, QFeatureso2 |
gridSingle, gridMulti | qidrN (one column per row) | QSatisfr1 |
gridNumber with direction: rows | qidrNcM | QBudgetr1c1 |
gridNumber with direction: cols | qidcNrM | QVolumec1r1 |
numberList, openList | qidrN | QSpendingr1 |
specify (attached text entry) | qidoNSpecify | QBrando99Specify |
lookup (single-step) | qid, qidFieldName | QZip, QZipCity, QZipRegion |
lookup (cascading step) | qidStepId, qidStepIdField | QVehicleMake, QVehicleModelBodyType |
| Loop iteration suffix | base_N | QBudgetr1c1_3 |
The gridNumber direction rule
gridNumber is the only question type whose column naming depends on a
property — direction.
direction: rows— totals shown per row → columns namedqidrNcMdirection: cols— totals shown per column → columns namedqidcNrM
Pick the direction that matches how the analyst wants to sum. Switching it later renames every column in the export.
Tri-state for coded options
When a question has coded options that fan out into one column per code
(multi, gridMulti), the column doesn’t store a simple 1/0. It stores
a tri-state:
| Value | Meaning |
|---|---|
1 | The option was shown to the respondent and selected. |
0 | The option was shown to the respondent and not selected. |
null | The option was not shown — masked by options.from, scale.from, or skipped via if. |
This distinction matters whenever you mask options at runtime. A null
means “they never saw this choice”, which is very different from “they
saw it and rejected it”. See Tri-state projection
for the full treatment.
Building a column name in Python
For analysis code or export-validation scripts, this is the exact rule expressed as a function:
import re
def format_col(qid, row=None, col=None, option=None,
field=None, loop=None, direction='rows'):
"""Build an export column name from its components."""
name = qid
if direction == 'rows':
if row is not None: name += f'r{row}'
if col is not None: name += f'c{col}'
else:
if col is not None: name += f'c{col}'
if row is not None: name += f'r{row}'
if option is not None: name += f'o{option}'
if field: name += field[0].upper() + field[1:]
if loop is not None: name += f'_{loop}'
return name
See also
- Tri-state projection — what
nullmeans in your data. - Loop suffixes — how loops compose with the naming rule.
- Long format — task-based export for CBC and MaxDiff.
- Glossary: qid — what makes a
qidvalid.