I would like to select the top 2 values from a constant sum field.

After that, I would like to use them as column fields in a grid.

Please advise.

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

I would like to select the top 2 values from a constant sum field.

After that, I would like to use them as column fields in a grid.

Please advise.

+1 vote

Assume your constant sum question is Q1.

We first sort the constant sum items in descending order. We do this via a constructed list. Let's call it "Q1SortedList".

The next constructed list will extract the highest scored item(s). Remember we may have equal scores, hence the reason we have multiple members stored in this constructed list. Let's call this constructed list Q1High1List. I have assumed you have 10 members in your parent list.

The Q1High1List constructed list will find all items that match the highest numeric score at Q1. We then randomise them.

We now create a similar constructed list to Q1High1List. Let's call it Q1High2List. This will find all items in your constant sum that match the 2nd highest score and then randomise them.

Note: the highest and 2nd highest scores can be the same. This technique will work fine either way.

The final constructed list (Q1Top2List) will simply bring together Q1High1List and Q1High2List and clean the list to 2 items as such ...

Use the Q1Top2List constructed list in your grid.

We first sort the constant sum items in descending order. We do this via a constructed list. Let's call it "Q1SortedList".

AddSorted(Q1,0)

The next constructed list will extract the highest scored item(s). Remember we may have equal scores, hence the reason we have multiple members stored in this constructed list. Let's call this constructed list Q1High1List. I have assumed you have 10 members in your parent list.

Begin Unverified Perl my $i=1; for($i=1; $i<=10; $i++) { if (VALUE("Q1_".$i)==VALUE("Q1_".LISTVALUE("Q1SortedList",1))) { ADD("Q1List",$i); } } RANDOMIZE(); End Unverified

The Q1High1List constructed list will find all items that match the highest numeric score at Q1. We then randomise them.

We now create a similar constructed list to Q1High1List. Let's call it Q1High2List. This will find all items in your constant sum that match the 2nd highest score and then randomise them.

Note: the highest and 2nd highest scores can be the same. This technique will work fine either way.

Begin Unverified Perl my $i=1; for($i=1; $i<=10; $i++) { if (VALUE("Q1_".$i)==VALUE("Q1_".LISTVALUE("Q1SortedList",2))) { ADD("Q1List",$i); } } RANDOMIZE(); End Unverified

The final constructed list (Q1Top2List) will simply bring together Q1High1List and Q1High2List and clean the list to 2 items as such ...

ADD(Q1High1List) ADD(Q1High2List) ListMax(2)

Use the Q1Top2List constructed list in your grid.

...