Unstack Multiple Form Responses in Google Sheets

Published on

You can use the following formula to unstack multiple form responses in Google Sheets:

=LET(unq, UNIQUE(identifier_data), HSTACK(unq, BYROW(unq, LAMBDA(row, TOROW(FILTER(variable_data, TRANSPOSE(QUERY(TRANSPOSE(identifier_data),,9^9))=TRANSPOSE(QUERY(TRANSPOSE(row),,9^9))))))))

Where:

  • identifier_data represents the user information part of the form responses.
  • variable_data represents the response data part of the form responses.

This formula works by treating one section of the data as a unique user identifier and another section as variable data that will be transposed. Each section can have any number of columns.

Example: Unstacking Form Responses in Google Sheets

Sample Form Response

Consider the following form responses stored in the “Form responses 1” tab:

Sample form responses before unstacking

This is event registration data recorded in Google Sheets, where users who registered for multiple events submitted separate form responses instead of selecting multiple events in a single submission.

As shown, some users have submitted multiple responses.

Let’s now unstack multiple form responses using the formula.

Unstacking Multiple Form Responses

In the dataset, we first need to identify:

  • Identifier Data → Columns B2:E6 (User information)
  • Variable Data → Column F2:F6 (Event Signed)

Now, enter the following formula in cell A2 of a new sheet:

=LET(unq, UNIQUE('Form responses 1'!B2:E6), HSTACK(unq, BYROW(unq, LAMBDA(row, TOROW(FILTER('Form responses 1'!F2:F6, TRANSPOSE(QUERY(TRANSPOSE('Form responses 1'!B2:E6),,9^9))=TRANSPOSE(QUERY(TRANSPOSE(row),,9^9))))))))

This formula will unstack multiple form responses, ensuring that each user’s event registrations appear in a single row.

Note: I suggest entering the formula in A2 because you may want to manually arrange the headers in the first row.

Example of unstacking multiple form responses in Google Sheets

Formula Breakdown

Step 1: Extract Unique User Information

UNIQUE('Form responses 1'!B2:E6)

This returns the unique user identifier data from columns B to E, ensuring that each user appears only once.

Step 2: Filter and Transpose Event Data

BYROW(unq, LAMBDA(row, TOROW(FILTER('Form responses 1'!F2:F6, 
TRANSPOSE(QUERY(TRANSPOSE('Form responses 1'!B2:E6),,9^9))=TRANSPOSE(QUERY(TRANSPOSE(row),,9^9))
))))
  • TRANSPOSE(QUERY(TRANSPOSE(…))) – Combines multiple identifier columns into a single-column reference (for comparison).
  • TRANSPOSE(QUERY(TRANSPOSE(row),,9^9))) – Converts the current row of unique identifier columns into a single-column reference (to match users).
  • FILTER(…) – Extracts the event data for each user by matching their unique identifier data.
  • BYROW(…) – Iterates through each unique user and arranges their event responses into a single row.
  • TOROW(…) – Converts the filtered results into a horizontal format.

Step 3: Stack the Data

HSTACK(unq, ...)

This horizontally stacks the unique user identifier data (unq) with the structured event data returned by BYROW.

The formula effectively unstacks multiple form responses into a structured format, ensuring each user’s event registrations appear in a single row.

Unstacking Multiple Form Responses with Dynamic Ranges

To ensure future form responses are also unstacked dynamically, replace fixed ranges with open ranges:

=LET(unq, UNIQUE('Form responses 1'!B2:E), HSTACK(unq, BYROW(unq, LAMBDA(row, TOROW(FILTER('Form responses 1'!F2:F, TRANSPOSE(QUERY(TRANSPOSE('Form responses 1'!B2:E),,9^9))=TRANSPOSE(QUERY(TRANSPOSE(row),,9^9))))))))

This ensures new responses are automatically included.

Using Structured Table References

Alternatively, you can use structured table references for better readability:

=LET(unq, UNIQUE(Form_Responses1[First Name]:Form_Responses1[Email ID]), HSTACK(unq, BYROW(unq, LAMBDA(row, TOROW(FILTER(Form_Responses1[Event Signed], TRANSPOSE(QUERY(TRANSPOSE(Form_Responses1[First Name]:Form_Responses1[Email ID]),,9^9))=TRANSPOSE(QUERY(TRANSPOSE(row),,9^9))))))))

Why Use Structured Table References?

  • Easier to read and manage
  • Auto-adjusts when new data is added
  • Improves formula maintainability

If you’re new to structured table references, check out this guide: Structured Table References in Google Sheets.

Conclusion

The unstack multiple form responses formula in Google Sheets allows you to efficiently reorganize form submissions, grouping related responses by unique users. Whether using standard ranges or structured references, this method ensures a clean, structured dataset for further analysis.

Additional Resources

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Expert Prashanth KV is a Diamond Product Expert in Google Sheets, officially recognized by Google for his contributions to the Docs Editors Help Community and featured in the Google Product Experts Directory. With years of experience working with Google Sheets and Excel for multinational firms in Mumbai and Dubai, he has been blogging since 2012, offering practical, real-world spreadsheet solutions that professionals rely on. Explore his blog to learn advanced formulas, automation tips, and problem-solving techniques to elevate your spreadsheet skills.

How to Count Merged Cells in Google Sheets (and Get Their Size)

Sometimes, you may have blocks of merged cells in a column or row. But...

Count Consecutive Workday Absences in Google Sheets

This tutorial offers a powerful formula-based solution to count consecutive workday absences in Google...

Top N Products and Top N Sellers in Google Sheets (Top N of Top N)

If you’ve ever wanted to compare which sellers contribute the most to your top-selling...

Use XLOOKUP in a Structured Table in Google Sheets (Single and Multiple Conditions)

This tutorial is for users who want to apply XLOOKUP inside a structured table...

More like this

How to Count Merged Cells in Google Sheets (and Get Their Size)

Sometimes, you may have blocks of merged cells in a column or row. But...

Count Consecutive Workday Absences in Google Sheets

This tutorial offers a powerful formula-based solution to count consecutive workday absences in Google...

Top N Products and Top N Sellers in Google Sheets (Top N of Top N)

If you’ve ever wanted to compare which sellers contribute the most to your top-selling...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.