Have an idea?

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

Grid column based: hide a column if no value was entered


In a previous question, the respondent is asked to enter up to four competitors in a grid/open-end question.

These entered values/competitors  are referred to in a new question. It is a grid question with 14 rows and 6 columns. The question takes the answers as input for the column name of column 3-6 (the first two column names are predefined).

The problem I have is that I only want to show the columns (with competitor name) for which previously a value/competitor has been entered. For example, when the respondent names two competitors in the grid/open-end question (in the first two fields), I only want to show column 1-4 (two predefined columns + 2 named competitors/columns), and leave out column 5 and 6.

Any help is much appreciated! Thanks in advance!

asked Jul 31, 2019 by Kris

1 Answer

0 votes
Kris, you can use some Perl script in a constructed list to assist with this problem.

I'll use a simple example. You will just need to exchange the variable names and list names.

Let's say your 4 competitors are captured in Q1-Q2-Q3-Q4 and these are O/E question types.

Create a parent list as follows and call it Q5ColList...

1-Competitor A
2-Competitor B

Items 1-2 are fixed and will always display Competitor A and Competitor B. Items 3-4-5-6 represent the answers from Q1-Q2-Q3-Q4 respectively.

The constructed list will look like this ...
Note: It will use Q5ColList as the parent list.
Begin Unverified Perl


 if (length(GETVALUE("Q1"))>0)

 if (length(GETVALUE("Q2"))>0)

 if (length(GETVALUE("Q3"))>0)
 if (length(GETVALUE("Q4"))>0)
 End Unverified

Use this constructed list in your grid question as the column list.

Items 3-4-5-6 will only appear if their respective questions have an answer of 1 character or greater.

And depending on your variable names, we can tidy up the script with a for loop. But the above will work just fine.
answered Jul 31, 2019 by Paul Moon Platinum (81,475 points)
edited Jul 31, 2019 by Paul Moon