Top 3 values

I have a list of integer question.type as follows:
integer q2_1 Tata Rallis
integer q2_2 Bayer
integer q2_3 Syngenta
integer q2_4 UPL
integer q2_5 Corteva
integer q2_6 BASF
integer q2_7 Indofil
integer q2_8 Cheminova
integer q2_9 Adama
integer q2_10 Excel
integer q2_11 Dhanuka
integer q2_12 Godrej
integer q2_13 PI

And I have a next set of question for which I have to ask for only for top three higher values coded in above question.

select_one q3 q3_1 Tata Rallis
select_one q3 q3_2 Bayer
select_one q3 q3_3 Syngenta
select_one q3 q3_4 UPL
select_one q3 q3_5 Corteva
select_one q3 q3_6 BASF
select_one q3 q3_7 Indofil
select_one q3 q3_8 Cheminova
select_one q3 q3_9 Adama
select_one q3 q3_10 Excel
select_one q3 q3_11 Dhanuka
select_one q3 q3_12 Godrej
select_one q3 q3_13 PI

There is no xpath function which can calculate top three. Probably you can do it combining some xpath operator. But my question is what would you do if top value is same for Tata Rallis and Bayer say 100, second top value also same for Syngenta and UPL say 80. Which three-item you would pick in this case? Again all of the items have probability scoring top 3 in a single entry. What would you do in this scenario?

In that case it will take first 3 in order of list and will ignore UPL. What has to be done in such scenario.

What you are asking for requires quite a detailed logic. I have tried getting it out here but you have to enhance the yellow ones for it to work perfectly. This will only give you the highest correctly otherwise use same logic to make it work for you.

See the attached sheet that gives an example of how to play with it.

Ranking to Select.xlsx (12.5 KB)



fine, it is done like a bubble-sort. (Would be great to have a sort function.)
Just to take care:

  • “the highest” can be 1 or all items (with the same max value).
  • the values must all be required (= yes)…

(@stephanealoo) Here is another (smarter?) option to get the cases with the highest values, using max(nodeset) function. (See
Ranking 02.xlsx (13.5 KB)

Unfortunately, the max function only allows a pure nodeset, but nothing like if, numeric or calculation. So, probably max can’t be used to find also top 2 and top 3 value.
Furthermore, it might be difficult to implement the limit (of khasab) to get only 3 top cases in total…

Another idea: Might it be interesting to think about changing the whole structure with the q-questions to a repeat structure?

Update: I tried to deploy the Ranking 02 example, which works well in preview. But creates an error for deployment. I a sorry and forwarded the issue to development.

Kind regards