As part of our core randomization options you have the ability to randomize or shuffle column and row order in a grid question. However, there is not a built-in feature to show a random subset of the rows in your grid question. Fortunately, it's pretty easy to script. We'll cover the steps to use a pretty simple script to accomplish just this. These steps assume a basic familiarity with SurveyGizmo and programming.
There are two approaches you might want to take when randomly showing a subset of rows from the grid.
- You might want to simply show a reduced number of grid rows to reduce respondent burden and fatigue and ultimately gather better data. This script is covered below in Option 1.
- You can also show a subset of rows based on the selected options from a previous question. This script is covered below in Option 1.
Option 1: Show a random subset of rows
See this script in action in an example survey.
OR
Add a survey with this script and setup to your account.
Features and functions used in this script:
- Custom Scripting Action
- Radio Button Grid question (can be used with any grid)
- tableshuffle
- hidequestion
Set up your grid question. Our example grid question looks like the below.
In the interest of reducing respondent burden and fatigue, we only want to burden each respondent with responding to three of the ten rows in this grid question.
To set this up we added a Custom Script Action to the top of the page with the grid question and pasted the below script.
--Row IDs to be randomly hidden go here. Make sure they are comma separated, no spaces, and inside quotes. rowsHideRandom = {3,4,5,6,7,8,9,10,11,12} --Number of rows you want shown from the list above. No quotes or commas are needed. shown = 3 --Do not change after this line. shuffled=tableshuffle(rowsHideRandom) for key,question in pairs (shuffled) do hidequestion(question,true) end for i=1, shown do hidequestion(shuffled[i],false) end
Required Customizations
In the script above you will need to customize variables highlighted in yellow in order to make the script work in your survey.
rowsHideRandom - Replace this list with the question IDs for your grid rows.
shown - Change this to the number of rows you wish to show.
Option 2: Show rows that correspond to previously selected options
See this script in action in an example survey.
OR
Add a survey with this script and setup to your account.
Features and functions used in this script:
- Custom Scripting Action
- Checkboxes
- Radio Button Grid (can be used with any grid)
- gettablequestionskus
- hidequestion
- getalue
- table.insert
- tableshuffle
Set up your source question and follow-up grid question. Our example source and grid questions look like the below.
We only want to burden each respondent with responding to a maximum of three rows that correspond to their selections in the previous Checkbox question.
To set this up we added a Custom Script Action to the top of the page with the grid question and pasted the below script.
source = 2 -- Multiple choice source question ID targetgrid = 3 -- Target Grid question ID shown = 3 --select 3 to show -- Replace the key text with the text of your row headers and the numbers with the row question IDs vals = {} vals["United"] = 6 vals["Delta"] = 7 vals["Southwest"] = 8 vals["Frontier"] = 9 vals["American"] = 10 vals["Alaska"] = 11 vals["JetBlue"] = 12 vals["Air Canada"] = 13 vals["Virgin America"] = 14 vals["Continental"] = 15 vals["Spirit"] = 16 --Get all the IDs for each row in target grid and set each to being hidden targetskus = gettablequestionskus(targetgrid) for key,question in pairs (targetskus) do hidequestion(question,true) end options_selected = getvalue(source) -- get all options selected rowidselection = {} -- a new array to hold the row ids of the grid to randomize from for key,value in pairs(options_selected) do table.insert(rowidselection, vals[value]) end --shuffle the array shuffled = tableshuffle(rowidselection) --set the rows to show for i=1, shown do hidequestion(shuffled[i],false) end
Required Customizations
In the script above you will need to customize variables highlighted in yellow in order to make the script work in your survey.
source - The question ID of the source question you wish to use to determine which rows will show.
targetgrid - The question ID of the target grid you wish to affect.
shown - Number of random rows to be shown.
vals - Replace the key text with the text of your row headers; make sure to preserve the quotes. The value numbers with the row question IDs.
Scripting and Other Custom Solutions
We’re always happy to help you debug any documented script that is used as is. That said, we do not have the resources to write scripts on demand or to debug a customized script.
If you have customization ideas that you haven't figured out how to tackle, we're happy to be a sounding board for SurveyGizmo features and functionality ideas that might meet your needs. Beyond this, check out our Professional Services; these folks have the scripting chops to help you to achieve what you are looking for!
Admin
— Dave Domagalski on 01/25/2019
@Steve: Thank you for your question!
The documented customization provided via Option 1 does not ensure an even showing of each row (it is truly random).
Having said that, what you are looking for should be possible with further customization to the existing script. I'm afraid that we do not have a documented script for this exact scenario.
SurveyGizmo's Professional Services team is available to contract for these types of customizations:
https://www.surveygizmo.com/programming-services/
I hope this helps!
David
Technical Writer
SurveyGizmo Customer Experience
— Steve on 01/25/2019
Using Option 1, is there any way to ensure an even showing of each row?
Admin
— Dave Domagalski on 01/04/2019
@Amanda: Thank you for your note!
I'm sorry for the trouble!
Upon checking the reference survey for Option 2, I did see a discrepancy in question and answer options IDs. I went ahead and fixed this in the survey.
If you download a copy to your account now, you should have a functioning script example.
If you are still seeing an issue with the script, please don't hesitate to reach out to our Support team and we can take a closer look:
https://help.surveygizmo.com/help/surveygizmo-support-hours
I hope this helps!
David
Technical Writer
SurveyGizmo Customer Experience
— Amanda on 01/04/2019
Your option 2 doesn't seem to be working, even in your live demonstration. When importing a copy to my account, I do notice some qids are off, but even fixing those doesn't seem to work. Has something fundamental changed, or is there just a little issue hiding somewhere?
Thanks!
Admin
— Dave Domagalski on 01/04/2019
@Anders.Enna: Thank you for your note!
While it is possible to randomize answer options (for example, checkboxes in a list), it does require customization via a script.
I'm afraid that we do not currently have a pre-built script for this exact scenario.
This is something that our Professional Services team could build as a custom solution:
https://www.surveygizmo.com/programming-services/
I hope this helps clarify!
David
Technical Writer
SurveyGizmo Customer Experience
— Henrik.Aalberg on 01/04/2019
Thanks for helpful article.
Is it also possible to randomise number og checkboxes (not in grid) in a list. For example show 5 put 25 brands.
Admin
— Dave Domagalski on 10/02/2018
@Sven: Thank you for your question!
Yes, the solution outlined in example one will work with a Checkbox Grid as well.
I hope this helps clarify!
David
Documentation Specialist
SurveyGizmo Customer Experience
— Alexander on 10/02/2018
Hi, if I want to use a checkbox grid instead of the radio button grid used in example 1, is that possible?
Admin
— Bri Hillmer on 04/17/2018
@Karla: I took a look at the survey you downloaded and it is working OK for me. I wonder if you are perhaps previewing the survey rather than looking at the live share link on the Share tab. If so, that might be the source of the trouble as actions, including scripts, do not run by default in preview. If you visit the share link on the Share tab you should see this in action. Alternatively, if you click the Preview link to try it out make sure to toggle the option to Fire Actions as shown in the below screen shot (this one gets me every time!):
https://www.screencast.com/t/U4MiFnTVKxs
As far as how the script itself it is important to understand how rows of grid questions work. As rows of grid questions are subquestions they get their own question IDs. Question IDs are just assigned as the survey is built. So, in the example survey the grid question is Question ID 5 and then the rows start at 8 (likely questions 6 and 7 were deleted as well as 10 since that is not in the list.) You'll need to find your question IDs for the rows; the easiest way to do this is via the Survey Legend:
https://help.surveygizmo.com/help/survey-legend
Once you know your row subquestion IDs you can replace that first part of the script with your specific question IDs and you should be all set!
I hope this helps!
Bri Hillmer
Documentation Coordinator
SurveyGizmo Customer Experience Team
— Karla on 04/17/2018
I'm unsuccessful at trying option 1. The test survey demo works. However when I select download an example into my acct, the survey unedited doesn't work in my acct. Am I on the wrong kind of license to run a custom script?
In the grey script text box, I see where to change # of rows you want to show randomly but don't see where you would edit the question id to tell the survey to which question to apply the custom script. Finally I'm confused on how to change which rows you want to impact: the sample survey has 10 rows and script is written to show 3 but the grey script references a range of more than 10 "%%questionsHideRan = "8,9,11,12,13,14,15,16,17,18" ;" isn't that where I would edit which rows to randomly hide? If I have 10 rows and want to randomly hide 10 and show 3, would I enter "1,2,3,4,5,6,7,8,9,10"? Thx for any guidance you can provide.
Admin
— Bri Hillmer on 04/17/2018
@Billy.lu: I've added example surveys that you can download for each of the approaches. I hope this helps!
Bri Hillmer
Documentation Coordinator
SurveyGizmo Customer Experience Team
— Rumiko on 04/16/2018
Is there a downloadable example I can test out in my account? I tried to use option 1 without success.
Admin
— Bri Hillmer on 01/16/2018
@Livia.brandao: The easiest way to solve this trouble would be to remove the back button. Here is some documentation on how to achieve this:
https://help.surveygizmo.com/help/remove-back-button
Beyond this, if you do not wish to remove the back button you could script a solution. Our professional services team can help you with a project like this. You can learn about programming services here: https://www.surveygizmo.com/programming-services/
Bri Hillmer
Documentation Coordinator
SurveyGizmo Customer Experience Team
— Ana on 01/16/2018
I've used option 1, but I'm facing a minor problem now. If after answering and proceed to next page, we wish to return to this page, a new set of options is shown. Is there a way to show the answered options when the back button is used?
Admin
— Dave Domagalski on 12/14/2017
@Corneliu: Thank you for exploring SurveyGizmo documentation content!
While we do have example scripts for a number of common customizations, I'm afraid that we do not have an example for your specific scenario as the script would require an additional layer of complexity.
Having said that, what you are looking to do does sound like something that can be accomplished via Custom Scripting.
If you do not have development resources directly on your team, I encourage you to explore SurveyGizmo's Programming Services offering:
https://www.surveygizmo.com/programming-services/
This team is available to contract for custom survey solutions such as the one that you referenced.
I hope this helps!
David
Documentation Specialist
SurveyGizmo Customer Experience
— Cmuntean on 12/13/2017
I've tried Option 1 Setup (above) and it works. (thanks for that!)
However, in my project I expect to encounter respondents with different levels of ”survey stamina”.
For those with ”higher survey stamina” I would like asking them, in a subsequent question, to answer another subset of randomly selected rows from the same initial grid, but without including the rows already selected in the previous question.
Considering your example with Rows1-10, within the subsequent question Rows 2, 4, and 5 would be a priori excluded .
Is there any possibility to create a Custom script for that purpose?
Corneliu