Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Display highest and lowest ranked item in a following question

I have a ranking question based on a constructed list that can have anywhere from 1-10 items (the 10th being a piped in "Other" response).


In two questions following the ranking question, I need to pipe in the top ranked item and the lowest ranked item in the body of a question.

How would I accomplish this?
asked Dec 2, 2020 by anonymous

1 Answer

0 votes
One way would be to create a constructed list with instructions like this:

AddSorted(RankingQ, 1)


"RankingQ" being the name of your ranking question, naturally.

That will give us an ordered list of the ranked items.  Now we can pull off the first or last items from the list with scripts like these:

[% ListLabel(list1, 1) %]


[% ListLabel(list1, ListLength(list1)) %]


"list1" being our new constructed list.
answered Dec 2, 2020 by Zachary Platinum Sawtooth Software, Inc. (161,250 points)
Of course, the highest and lowest ranked items will be the same in the case that the constructed list fed into the ranking question only has one item.  I'm not sure what you want to happen in that situation.
So....what is the difference in the script used to call the first and last item in a subsequent question text?


(I'm just a little confused!)
The first ListLabel script should return the highest ranked item, while the second should return the lowest ranked item.  That's what the ListLabel function does: it returns the item text for a certain item in a list.  The first ListLabel script uses the value 1 to return the first item in our new constructed list.  In the second script we want to return the last item of the list, but because the list doesn't have a guaranteed length, I used the ListLength function to know how many items ended up in the list.

Does that make sense?
...