Skip to content

Primary Keys, Codeframes & Multi-Response Variables

Three bits of structure make a data store work well with the rest of the platform. A primary key tells records apart. Codeframes give numeric codes their meaning. Multi-response variables keep “choose all that apply” questions together.

You’ll find all three on Variable View. For the basics of that tab, see Manage variables.


The primary key is the variable that identifies each record, like a respondent ID or an order number. It must be unique (no two records share a value) and filled in on every record.

When you import or update data later, Data Wrangler uses the primary key to match incoming rows to existing records. A data store without one treats every incoming row as a new record.

Other apps need one too: Case Manager, Text Explorer and Action Connect can only use a data store that has a primary key.

  1. Select the variable - On Variable View, tick the one variable you want as the key.
  2. Click Set Primary Key - It’s in the action panel. There’s no confirmation; Data Wrangler checks the data and applies the change straight away.
  3. Check the result - You’ll see ”’…’ is now the primary key.” and a key icon next to the variable.

Setting a new primary key replaces the old one. In Variable View, a primary key is always a single variable. To combine several columns into a key, do it when you import the file.

You can also tick Set as primary key when you add a variable, if the data store doesn’t have a key yet.

Tick the current key variable and click Unassign Primary Key. It happens straight away, and you’ll see ”’…’ is no longer the primary key.”

You can’t set or unassign the primary key when:

  • the data store is published. The owner can unlock it with Edit Schema.
  • it’s a survey data store. The key is always the survey response.
  • the variable uses Wipe or Mask + retention. See Personal information.

A codeframe maps numeric codes to labels, like 1 = “Very satisfied” and 2 = “Satisfied”. The data stores the codes; the labels are what people see in Data View with Show Labels, in exports set to Labels, and in other apps.

You can add a codeframe to an Integer or Number variable that was added in this data store (not one that came from a survey). Codeframes work on published data stores too.

In the Codeframe column, you’ll see:

  • Add: no codeframe yet
  • Manage: edit the existing codeframe
  • View: a read-only look, for multi-response variables or if you can’t edit
  • an info icon, when a codeframe isn’t possible. Hover over it to see why.
  1. Click Add or Manage - The Codeframe dialog opens.
  2. Add an entry - Enter a Code (a number) and a Label, then click Add Entry. If you leave the label blank, the code is used.
  3. Edit or remove entries - Click a label to change it, or click Remove Entry to delete a code.
  4. Click SAVE - You’ll see “Codeframe saved successfully.” It’s saved straight away.

Copying a codeframe from a questionnaire? Bulk Edit turns it into codes in seconds.

  1. Click Bulk Edit - In the Codeframe dialog.
  2. Paste one entry per line - Put the code first, then the label, for example:
    1 Very satisfied
    2 Satisfied
    3 Neutral
    The table above previews the result as you type.
  3. Tidy up if needed - Tick Strip full stops if your codes look like 1. or 2..
  4. Click SAVE.

Lines that don’t start with a number are skipped, and so are repeated codes; you’ll see how many. Click Row Edit to switch back.

Click Remove in the Codeframe dialog to clear every entry, then click SAVE. You’ll see “Codeframe removed successfully.”


A multi-response variable groups several Yes/No variables into one “choose all that apply” question. For example, q5_1 “Email”, q5_2 “Phone” and q5_3 “Chat” become a single question, “How did you contact us?”

To create a new multi-response variable from scratch, see Add a multi-response variable. To group variables you already have, use Define Multi Response.

  1. Select the variables - On Variable View, tick two or more variables.
  2. Click Define Multi Response - It’s in the action panel. The Define Multi Response dialog lists “The following variables will be grouped:”.
  3. Name the group - Enter a Label; Data Wrangler suggests a Multi-response variable name from it. The name follows the usual naming rules.
  4. Click DEFINE - The group is created straight away, with your variables nested underneath it.

Data Wrangler doesn’t check what’s in the variables you group, so make sure they’re the Yes/No columns of a single question. You can’t group a variable that’s already a multi-response variable.

Click Ungroup Multi-Response on the group’s row, then YES. The group is removed, and its variables go back to being separate variables. You’ll see “Multi-response variable ”…” ungrouped successfully.”

You can’t group or ungroup variables on a published data store.


Survey data stores have some limits:

  • The primary key is always the survey response, so you can’t change it.
  • You can add codeframes to Integer and Number variables you added yourself.
  • You can group and ungroup variables you added yourself, but not ones that came from the survey.

See Survey data stores.


Does every data store need a primary key?

No, but it helps. Without one, every row you import later is added as a new record, so you can’t update existing records.

Can I use more than one variable as the primary key?

Only when you import a file. In Variable View, the primary key is always a single variable.

Why don’t I see Set Primary Key?

Select exactly one variable that isn’t the key already. Set Primary Key isn’t available on published or survey data stores.

Why can’t I add a codeframe?

Codeframes are only for Integer and Number variables added in this data store. Hover over the info icon in the Codeframe column to see the reason.

Can my codes be text, like “A” or “B”?

No. Codes must be numbers. Put the text in the label instead.

What’s the difference between Ungroup Multi-Response and deleting the variable?

Ungroup Multi-Response removes only the group and keeps the child variables. Deleting a multi-response variable deletes the group and all its child variables, with their data.


”’…’ cannot become the primary key: … value(s) appear on more than one record.”

Section titled “”’…’ cannot become the primary key: … value(s) appear on more than one record.””

Some records share a value, so the variable can’t identify them uniquely. The message shows examples.

  1. Check the examples - Find the duplicate values in Data View.
  2. Choose another variable - Pick one that’s unique for every record.
  3. Or fix the data - Correct or remove the duplicates, then try again.

”’…’ cannot become the primary key: … record(s) have no value for it.”

Section titled “”’…’ cannot become the primary key: … record(s) have no value for it.””

A primary key must have a value on every record.

  1. Fill the gaps - Add the missing values, or choose a variable that’s always filled in.

”’…’ cannot become the primary key yet: … record(s) are still being processed.”

Section titled “”’…’ cannot become the primary key yet: … record(s) are still being processed.””

An import or other change is still running.

  1. Wait and retry - Give it a few minutes, click Refresh Data, then try again.

”Variables using Wipe or Mask + retention cannot be assigned as primary keys: …”

Section titled “”Variables using Wipe or Mask + retention cannot be assigned as primary keys: …””

Fields whose values are erased can’t identify records.

  1. Choose another variable - Or change the field’s personal-information handling first. See Personal information.

”Code must be numeric” or “Code already exists”

Section titled “”Code must be numeric” or “Code already exists””

Each code must be a number, and each number can only be used once. 1 and 01 count as the same code.

  1. Fix the code - Enter a different number.

”Codeframes can only be changed for USER-owned numeric variables.”

Section titled “”Codeframes can only be changed for USER-owned numeric variables.””

The variable came from a survey or isn’t numeric.

  1. Use a numeric variable you added - Add an Integer variable and give it the codeframe instead.

”’…’ is already a multi-response variable and cannot be grouped again.”

Section titled “”’…’ is already a multi-response variable and cannot be grouped again.””

You selected a multi-response variable along with the others.

  1. Change your selection - Untick the multi-response variable and try again.