Question type

rank

Coded items in chosen order. The respondent picks how items rank against each other; the runtime stores the codes in rank order — first place to last.

What rank is

rank collects coded items in the order the respondent prefers them. The stored answer is a collection of codes in rank order — index 0 is the top-ranked item, index 1 is second, and so on. Use it when relative position matters more than presence — “rank these features by importance”, “order these brands by preference”.

Mockup preview
QTop3 rank rank
Rank these features by importance.
Most important first.
- qid: QTop3
    type: rank
    text: Rank these features by importance.
    instruction: Most important on top.
    exact: 3
    options:
        1: Battery life
        2: Camera quality
        3: Screen size
        4: Build quality
        5: Price

exact: 3 forces the respondent to fill exactly three rank positions. Without it, all options can be ranked or only some.

Properties

PropertyValuesNotes
qidstringRequired. Unique within the survey.
typerankRequired.
title, text, instructionrenderableVisible content. Use {{ }} to pipe runtime values. HTML allowed.
requiredTrue | FalseDefault True.
default.errorsTrue | False | custom stringDefault True.
validationcode blockPython; call fail() to reject. No default.
readonlyTrue | FalseDefault False. Set True to render the question but disable input — the respondent sees it but can’t change the ranking. Pair with visibility: hide to fully hide a helper question.
visibilityshow | hideDefault show.
styledrag | arrows | tapToRank | dropdownRank | podiumDefault drag. See Styles below.
orderfixed | random | randomEach | flip | alphabetical | reverseDefault fixed. Controls the starting order before the respondent reorders. See below.
group.ordersame as orderDefault fixed. Order of named groups when group: is used.
layout.colsintegerDefault 1.
minintegerMinimum positions to fill. No default.
maxintegerMaximum positions to fill. No default.
exactintegerExactly this many positions. Overrides min / max. No default.
optionslist name or inline domainRequired when group: is not used.
options.fromexpressionFilter the visible options at runtime. No default.
groupgrouped list nameRequired when options: is not used.
customcode blockCustom runtime block. No default.

order values

ValueBehaviour
fixedRender options in authored order before the respondent reorders. Default.
randomStable random starting order, per respondent.
randomEachRe-shuffle the starting order every render.
flipDeterministic split sample — half see authored, half see reversed.
alphabeticalSort the starting order alphabetically by label.
reverseReversed authored order as the start.

order only affects the initial order presented to the respondent. Once they rank, their chosen order is what’s stored.

Group properties

When using group: to subdivide options, each named group can carry:

PropertyValuesNotes
optionsgrouped option entriesRequired.
show.labelTrue | FalseDefault True. Set False to hide the group header label.
anchorTrue | FalseDefault False. Set True to pin the group in place under group.order: random.

Per-option properties

PropertyValuesNotes
labelrenderableRequired when expanding the option. Use {{ }} to pipe runtime values.
imageURL stringOptional thumbnail.
anchorTrue | FalseDefault False. Set True to pin the option in place under order: random.
isolateTrue | FalseDefault False. Set True to render this option in a separate group, outside the main rank list. Picking an isolated item does not assign it a rank position; it acts as a parallel toggle. To make it also clear the rest of the ranking when picked, add exclusive: True on the same option.
exclusiveTrue | FalseDefault False. Picking this option clears any existing ranking for the others. Rare on rank — most authors use a separate single “Did you actually rank these?” question instead.
specifyTrue | FalseDefault False. Attach a free-text input to this option (collected only when the option is ranked).
specify.sizeintegerWidth of the specify input. No default.
specify.maxCharintegerMax length of the specify text. No default — unlimited unless set.
dataobjectMetadata object for advanced authoring. No default.

Methods & accessors

The runtime values you read in scripts, conditions, validation, and piping. Return types are exact — see the Glossary for what Code, CodeSet, Label mean.

Accessors

ExpressionReturnsMeaning
Q.selectedCodeSetCodes in rank order. Index 0 is the top-ranked code.
Q.selectedLabelsLabelListLabels in rank order, parallel to Q.selected.
Q.valuesCodeListAlias for Q.selected. Some authoring contexts read more naturally as “the values” — both produce the same data.
Q.allCodeSetAll visible option codes (the effective domain).
Q.allLabelsLabelListLabels for Q.all.
Q.answeredboolTrue once the respondent has filled at least one rank position (or the required minimum).
Q.notAnsweredboolInverse of answered.
selected is in rank order, not authored order. If the respondent ranks Sony first and Apple second, QTop3.selected is {3, 1}, not {1, 3}. The same applies to selectedLabels and values.

Methods

ExpressionReturnsMeaning
Q.set([2, 1, 3])NoneSet the ranking to an ordered list of codes. The list order is the rank order.
Q.reset()NoneClear the ranking.
Q.at(N)CodeCode at zero-based rank position N — alias for Q.selected.at(N).

Q.set() only accepts an ordered list — there’s no scalar or tri-state form on rank. Duplicates and unknown codes are rejected.

Collection operations on Q.selected

ExpressionReturnsMeaning
Q.selected.sizeintNumber of ranked positions filled.
Q.selected.at(N)CodeThe code at rank position N (zero-based).
Q.selected.any(N)boolTrue if code N is anywhere in the ranking.
Q.selected.any([1, 2])boolTrue if any listed code is ranked.
Q.selected.intersect([1, 2, 3])CodeSetOverlap between the ranking and the list, preserving rank order.

The same operations work on Q.selectedLabels, Q.values, Q.all, and Q.allLabels. See Collections for the full reference (including every, union, minus).

Skins

Five visual styles. Pick by context — list length, whether the respondent is on a touch device, and whether ranking the full list matters or just a top few.

drag Drag (default)
Pool
Apple
Sony
Ranked
1Samsung
2—
Two-column layout — pool on the left, numbered slots on the right. Drag items into slots, drag between slots to reorder.
arrows Arrows
1 Samsung ▴▾
2 Apple ▴▾
3 Sony ▴▾
Single list with up/down buttons per item. Same shape as drag, button-driven instead of drag-driven.
tapToRank Tap to rank
1 Samsung
Apple
Sony
Available items as large tappable cards. Tap an item to give it the next rank position; tap again to remove. Good on mobile.
dropdownRank Dropdown
1
Samsung▾
2
Apple▾
3
—▾
One dropdown per rank position. Useful for fixed-position rankings (Top 3, Top 5) where the position matters more than the list.
podium Podium
2
Apple
1
Samsung
3
Sony
Top-3 podium with chip pool below. Designed specifically for top-3 rankings; pair with exact: 3.

The exact appearance is driven by theme tokens — colours, radii, fonts. Every survey is themable from the theme builder; the previews above use defaults. See Customisation and Skin variants.

See it work

A working preview. Tap an item to give it the next rank position; tap again to remove it (the others re-number automatically).

Mockup preview
QTop3 rank rank
Rank these features by importance.
Tap items in order. Most important first.
Live state
QTop3.answeredFalse
QTop3.selected{}
QTop3.selectedLabels{}
QTop3.values{}
QTop3.selected.size0
QTop3.selected.at(0)None
- qid: QTop3
    type: rank
    text: Rank these features by importance.
    instruction: Most important first.
    options:
        1: Battery life
        2: Camera quality
        3: Screen size
        4: Build quality
        5: Price

The interaction shown here is “tap to add to next position” — the shipping styles (arrows, drag, podium, etc.) will offer richer UIs but the underlying state model is the same.

Methods & accessors — live

The same preview, paired with a panel of expressions evaluating against the current ranking. Rank some items above and watch each expression’s return value.

Mockup preview
QTop3 rank rank
Rank these features by importance.
Methods & accessors — live
QTop3.answered → —
QTop3.selected → —
QTop3.selectedLabels → —
QTop3.values → —
QTop3.selected.size → —
QTop3.selected.at(0) → —
QTop3.selected.at(1) → —
QTop3.selectedLabels.at(0) → —
QTop3.selected.any(2) → —
QTop3.selected.any(99) → —
QTop3.selected.intersect([1, 2, 3]) → —

A few things to notice as you rank:

  • selected reflects rank order, not authored. Rank Sony (code 3) first then Apple (code 1) — selected is {3, 1}.
  • .at(0) is the top-ranked code, .at(1) is second. This is the most-used method on rank.
  • selectedLabels is the human-readable parallel to selected — same order, labels instead of codes. Useful for piping the top rank into a follow-up question.
  • The “None of these” item is isolate: True and exclusive: True. isolate puts it in its own group below the main list; exclusive makes picking it clear the rest of the ranking. The two flags are independent — use isolate alone for purely visual separation, add exclusive: True when “this option means the others don’t apply”. Tap “None of these” and watch the previous rankings clear, with selected.any(99) flipping to True.

Examples

Top three with exact

- qid: QTop3
    type: rank
    text: Rank your top three features.
    instruction: First, second, and third.
    exact: 3
    options:
        1: Battery life
        2: Camera
        3: Screen
        4: Build
        5: Price

The respondent must fill exactly three positions. With min: 3 / max: 3 the rule is the same; exact is just clearer.

Rank a respondent’s earlier selections

- qid: QFeatures
    type: multi
    text: Which features matter to you?
    min: 3
    options: featureList

- qid: QRankFeatures
    type: rank
    text: Now rank the features you picked.
    options.from: QFeatures.selected

The rank only shows options the respondent picked at the previous multi. options.from filters the rank’s domain.

Pipe the top-ranked label into a follow-up

- qid: QTop3
    type: rank
    text: Rank these brands.
    options: brandList
    exact: 3

- qid: QTopReason
    type: open
    text: Why did you rank {{ QTop3.selectedLabels.at(0) }} first?
    style: textarea
    input.rows: 3

selectedLabels.at(0) is the top-ranked brand’s label. Pipe it straight into the next question’s text.

Read positions in a script

- script: |
    print("First:",  QTop3.selectedLabels.at(0))
    print("Second:", QTop3.selectedLabels.at(1))
    print("Third:",  QTop3.selectedLabels.at(2))

    # Was a specific code ranked at all?
    if QTop3.selected.any(5):
        print("Price was ranked at position", QTop3.selected.at(0) == 5)

.any(N) checks if a code is anywhere in the ranking; .at(N) reads a specific rank position.

Hidden helper that mirrors a ranking

- qid: hTop1
    type: single
    options: brandList
    visibility: hide
    readonly: True
    required: False

- script: |
    if QTop3.answered:
        hTop1.set(QTop3.selected.at(0))

hTop1 stores just the top-ranked brand as a single-style answer — useful when downstream analysis wants a flat “first choice” column instead of working with the ranked list.

Validation example

- qid: QTop5
    type: rank
    text: Rank up to five.
    max: 5
    options: brandList
    validation: |
        # Require at least 3 ranked.
        if QTop5.selected.size < 3:
            fail("Please rank at least three brands.")
        # Don't let "None of these" be ranked first.
        if QTop5.selected.at(0) == 99:
            fail("Please rank an actual brand first.")

Validation runs after the respondent ranks, before the next page. Calling fail() rejects with a message; multiple fail() calls short-circuit on the first that fires.

Reusing an option list

- lists:
    brandList:
        options:
            1: Apple
            2: Samsung
            3: Sony
            4: LG
            99: None of these

- qid: QRankBrands
    type: rank
    text: Rank these brands by preference.
    options: brandList
    exact: 3

For the full reusable-list pattern see single.

Export

rank exports one column per rank position:

WhatColumn
Code at rank 1qidr1 (e.g. QTop3r1) — the first-ranked code
Code at rank 2qidr2
……

Positions the respondent didn’t fill (when exact isn’t set) export as null.

QTop3r1 = 3       # Screen size, ranked first
QTop3r2 = 1       # Battery, ranked second
QTop3r3 = 5       # Price, ranked third
QTop3r4 = null    # not ranked
QTop3r5 = null

The number of qidrN columns equals the size of the visible domain — so a 10-option rank produces qidr1 through qidr10, with the unfilled positions as null.

See also