# Randomise 5 questions and select only one by using macro in Survey Solutions

In my questionnaire, I have two modules where I will randomize the questions. The first one involves using syntaxes (expressions) to randomly order three choice sets (each choice set contains 6 options to choose). Below is the expression used to order the choice sets randomly:

long Integer called random_tp
(int)Math.Floor((7-1)*Quest.IRnd() + 1)

The second is about creating a macro to choose one question out of 5. This section will ask respondents about their willingness to pay for insurance in which there are 5 prices that should be picked up randomly (see below the 5 options of WTP).

[WTP] is randomly selected by Field Supervisor from the following list:

1. PEN 2.50 (US\$ 0.65)
2. PEN 15.00 (US\$ 3.87)
3. PEN 25.00 (US\$ 6.45)
4. PEN 50.00 (US\$ 12.91)
5. PEN 125.00 (US\$ 32.27)

Could somebody help in creating the macro, please? Below is my attempt but I failed so far:

var r = ((int)Math.Floor(rndum.Value*5.00) + 1)Quest.IRnd();
var s = r.ToString(“0.0000000000”);
var items = new[1,2,3,4,5]{
“wtp1_1”,
“wtp2_1”,
“wtp3_1”,
“wtp4_1”,
“wtp5_1”};

``````for (var i = 0; i < items.Length; i++)
{
var n = Convert.ToInt32(s.Substring(i,1));
if (n >= items.Length) n = 0;
var t = items[i];
items[i] = items[n];
items[n] = t;
}
``````

return items

This results in showing the 5 questions as opposed to choosing one question out of 5.

I am using expressions and a macro to make sure the randomization is not correlated in both modules.

Any help is worth it!
Thank you

On the surface it looks like you don’t need five questions, but rather just one with a substitution of a random numeric value. Or am I missing something?

Hi sergiy

First, the below picture shows the first randomization in which I randomize the sequence in which each choice ser appears to the respondent. Each choice set has 6 pairs of options.

Second, in the second below picture, I randomize the WTP to select one price of 5 alternatives. The problem is that both randomization are correlated which means the random selected are identical in both sections.

I am thinking if I create a Macro to randomize the 5 WTP prices, the issue of randomization process correlation could be fixed.

Could you please help me in creating the macro? Is there another way of making the two randomizations work independently?