Skip to main content

Understanding Choice Codes

What are choice codes?

Every choice in a single choice or multiple choice question, every answer in a grid question, and every statement in a grid question has a code - a unique number that identifies it in your data. Codes are what appear in your exported data file and reports when responses are recorded.

By default, Rival assigns codes automatically based on the order choices are added: the first choice gets code 1, the second gets code 2, and so on.

With custom choice codes, you can take control of these numbers and assign your own codes - making it much easier to combine data across multiple survey waves or studies.


How codes are assigned

A choice, grid statement, or grid answer can be in one of three states:

1. No code set yet (system will calculate)

You haven't assigned a code to this item. Rival will calculate a code for it automatically at preview (temporarily) and lock it in when you publish. The code assigned follows a gap-filling approach - starting from 1 and filling the lowest available numbers.

2. You've set a code (user-assigned)

You've explicitly assigned a code via bulk import. That code is saved immediately and will be used at preview and publish. You can update it at any time before the question is published.

3. Published

The question has been published. All codes are now permanently locked and cannot be changed. This ensures your data stays consistent throughout data collection.

Item-level locking: Publishing locks codes at the individual item level, not the whole survey. If you publish a question and then add new choices or statements afterward, those new items don't have locked codes yet - you can still assign or change their codes before publishing again.


The gap-filling algorithm

When Rival calculates codes automatically, it uses a gap-filling approach:

  1. It looks at all codes already in use - including any you've set manually, codes from published items, and codes from items that were published and then deleted

  2. Starting from 1, it fills the lowest available gaps

  3. It assigns codes sequentially through available numbers

Example: If you have 5 choices and have manually set codes 5 and 10, Rival fills in 1, 2, 3, 4 for the remaining choices (skipping 5 and 10).

This keeps your codes compact and predictable rather than continuously incrementing to high numbers.


Code spaces

Codes only need to be unique within their own group:

  • Choices in a question share one code space (unique within that question's choices)

  • Grid answers share a separate code space (unique within that grid's answers)

  • Grid statements share their own code space (unique within that grid's statements)

This means a grid question can have statement code 5 and answer code 5 - they live in separate spaces and don't conflict.


What happens when you duplicate a survey?

When you duplicate a survey, all codes carry over to the new survey. The duplicated survey starts in an unpublished state, so:

  • Items that were published in the original become unpublished items with your assigned codes in the new survey - their codes won't recalculate

  • Items that had manually assigned codes keep those codes

  • Items without any assigned codes carry over without a code and will be recalculated at the next preview or publish

This is particularly useful for tracker studies - duplicating a published Wave 1 survey gives you Wave 2 with all the same codes ready to go.

Did this answer your question?