First rank and then select from ranking

Hey all,

I created an multiple choice question (max three choices), which is ranked with the rank widget. Now, I would like to enter a value (by using the decimal question type 3 times) for each ranked value with in the label a reference to the ranked value. If you want to refer in the label to a stored value, the ${Value} is needed. However if I use the value where the ranked selected multiple choices is stored, all the choices are visible, while I only want to show the first, second or third ranked choice. Is that possible?

Here Trial_errors.xlsx (14.5 KB), the example can be found. I have used Select_multiple choices, then rank the selected choices - #4 by PEPUKAI_PRINCE_CHIVE - Support - ODK Forum for inspiration.

You may try to use selected-at, see ODK XForms Specification, with a calculate variable (3*) and than reference this variable in the label.

Maybe this previous discussion is also interesting for you Show selected options as selected.


Thanks for this answer. It helped a great deal!

However, I do have a another question related to this question.

Now, I am able to select based on index the stored ranked answers. However, when I refer to the calculate variable in the label below with ${Variable}, then it shows the stored ‘name’ ranked value, while I would like to show the name that is written in the ‘label’. I tried to use for example jr:choice-name(selected-at(${rankCoarse},0),'${rankCoarse}') to solve this, but it gives "undefined’ instead the value stored in the ‘label’ section when validating this form:


See the form Trial_errors.xlsx (14.6 KB). Can anyone help me to fix this problem?


It seems as you need to reference the initial choice_list (instead of the rank) to get the label:
and so on.
This referencing is similar to a previous example (see link above): Show selected options as selected - #7 by wroos.

But even jr:choice-name(‘aRankedChoiceName.’, ‘${rankQuestion}’) will show “undefined”.
(As I tested, it is the same without a choice_filter.)
And in table view and Excel export, it seems that you cannot get the labels for a rank!
This is strange for me. It might be a bug? Maybe someone of the core team can explain: @Kal_Lam, @Josh ?


Thanks @wroos, I can confirm that this is the case and have opened an issue:

1 Like

Dear @Josh,
thanks! The problem is not only the export, but also in

  • the table view (label option) and
  • jr:choice-name() for a rank question.

Maybe there is even an issue in the generated XForm?
Kind regards

Hi @wroos, thank you for expanding. Here’s an issue for the table view. The jr:choice-name() issue will perhaps be in in Enketo or pyxform, maybe Collect too but I haven’t tested it.


Thanks for the feedback! And I unexpectedly appear to find a bug.

I have a question about jr:choice-name(‘*aRankedChoiceName*.’, ‘${rankQuestion}’. The ‘aRankedChoiceName’ returns the selected choice name answer from the user and ‘rankQuestion’ refers to the question itself and pulls the label of the selected choice name from the referred question?

Yes, see above for your example.

Hi @Josh,
See also Rank type missing in XLSForm Reference Table

1 Like

Hello @Webex,
Side-note: You use special characters in some choices/question names, e.g. -, > and names not beginning with a character. This might create problems for data usage and analysis in other tools, like SPSS.

And here is another option for a “ranking” design:
Ranking_Option02.xlsx (34.2 KB)
You could use it also without relevant.
(Based on

First step

Third step

But I would prefer using the rank type.

1 Like

Thanks for thinking along how work around this bug of ranking! The first option would also be my first choice. In this request for assistance, First rank and then select from ranking - #7 by Josh, is mentioned that KoboCollect may not have this bug. I will test that first. Maybe I won’t have to implement this second option, I will let you know!

And thanks for the side-note!

1 Like

Hello @Webex,
in your case, you only need to change the reference in your jr:choice, please, as explained above:

This will works for Enketo!

1 Like

After some testing, it appears that KoboCollect does not have this bug. So, that is nice.

for your example this works in Enketo (and in Collect): Reference the initial choice_list, not the rank-list.