I have a Google Form that asks people to fill out their name, gender, and then their size preference for shirts and pants. The form automatically outputs the 2 sizes in separate columns.
I want to combine the size columns while retaining the name and gender of the respondents, like this:
I know I can use arrays and queries to do this:
={query({A16:D18},"select Col1, Col2, 'Shirts', Col3 where Col1 is not null");
query({A16:D18},"select Col1, Col2, 'Pants', Col4 where Col1 is not null")}
Which gets me exactly what I want. But I'm trying to make it dynamic in case I need to add more questions in my form about sizes (which increases the # of columns).
Right now if more columns are added, I would have to add another query() line manually and make it look like this:
={query({A16:D18},"select Col1, Col2, 'Shirts', Col3 where Col1 is not null");
query({A16:D18},"select Col1, Col2, 'Pants', Col4 where Col1 is not null");
query({A16:D18},"select Col1, Col2, 'Dresses', Col5 where Col1 is not null")}
Is there any way to dynamically add another query()
line if I tell it to look for 3 columns now?
I know this seems like weird request if I'm willing to enter in "3" manually - but I want other people in my company to be able to use this spreadsheet and asking them to manually change the # of columns is easier an less error-prone than having them modify the formula.
I know how to dynamically change the Col#
, just not the extra query line...