Have an idea?

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

Constructed list in a loop

I have used loops from time to time at a basic level but I can’t believe I haven’t come across this situation before.

I have a question called B3 which I loop.

My loop is called B3Loop and my anchors are B3-B3.
I have 9 colours as my step-through (or loop) but my constructed list randomly selects 4 colours. No more, no less!

Here's how I would like to ask the question for the 4 colours ...

Colour 1: Which brands apply to this [1st random colour selected]? I display 13 brands.

Colour 2: Which brands apply to this [2nd random colour selected]? I would like to display all 13 brands less the Colour 1 answer.

Colour 3: Which brands apply to this [3rd random colour selected]? I would like to display all 13 brands less the Colour 1 and Colour 2 answers.

Colour 4: Which brands apply to this [4th random colour selected]? I would like to display all 13 brands less the Colour 1 and Colour 2 and Colour 3 answers.
My parent list is B3List which contains the 13 brands.
My constructed list looks like this ...
The removal of the brands is not working. I suspect I have not applied the correct script for removing brands from the loop?
I’m also aware that once a constructed list has been established, that’s it. It does not re-evaluate.

How do I remove the brands selected at the previous loop iterations?
asked Aug 13 by Paul Moon Platinum (55,825 points)
retagged Aug 13 by Walter Williams
I could hide the selected response options with JavaScript, but I don't think there's going to be any constructed list Perl to easily keep those response options from existing at all.  Like you said, constructed lists only evaluate once.  The easiest solution for situations like this might be to toss the loop and use four constructed lists, I'm afraid.
Zachary, it kind of defeats the purpose of the loop in situations like this.

I had to create 4 select questions using 4 constructed lists for the brands and display the labels of the colours from the colour constructed list.

If you don't mind, I wouldn't mind seeing the JavaScript solution to hide the answers from the previous questions. No rush.
Zach, I was trying to look at this for Paul as well.  I'm curious about the constructed lists being evaluated only once.  I went through a loop exercise in which the constructed list was altered with each iteration using a Pass-In variable.  I just couldn't get it to work by calling the responses to that question in the normal fashion.  When I looked at my data, it showed a different dot notation for the constructed list.  Wouldn't that indicate the constructed list being evaluated multiple times?

1 Answer

0 votes
So this is a little wonky in that some things work in loops and some don't.

If you look at the data, constructed lists indeed follow the dot notation and build a constructed list each time you loop.  Using a function like RIC() just doesn't work and I'm not sure why.  However, the normal Remove() function does work, and you can reference the dot notation answers like this for the constructed list


I tested this out and each brand disappeared during the loop as I chose it.

I'll see if I can get the looping documentation updated to reflect this.
answered Aug 14 by Brian McEwan Gold Sawtooth Software, Inc. (36,985 points)
Thanks for clearing it up Brian, that seems to work well.
Thanks Brian, I will check this out later today. Does it work when randomising the loop iterations? That's the first thing that comes to mind.

I'll get back to this post once I have conducted the tests.
It should work because the constructed list is built for each loop iteration.  I don't think the order of anything happening should matter.
Thanks Brian, I managed to get back to this and test it with non-randomised and randomised iterations. All good. Worked like a charm.

As you could see, I tried using the RIC method which seemed the way to go but you have kindly pointed out using the Remove function instead is the answer.

Just pop that additional script into the HELP and I think we're done here.

Thanks again for chipping in.
I think it's because RIC is just wanting a single question name, and Q1 doesn't exists in the data because it's looped.  But Q1.1 isn't a question name, so I don't think any of those intelligent add/remove functions will work with looping without changes to the underlying way it's all programmed.
The good news is Brian is the Remove function does the job just nicely. And as long as you pop that into the HELP that should inform others.