Google Apps Script, Google Sheets, SpreadsheetApp, 2d arrays
In our previous tutorial, we created a 2d array of count values for each item chosen in a survey form in Google Apps Script. In our survey, we asked users to submit what type of goat they are. We didn’t know what species of goat they identified as so we just needed to count for any goat species that was submitted.
In part 2 of our course, our Google Sheets survey data is a little different. This time around we are asking the human companion of their coding goat to:
Rate your goat’s athleticism.
Respondents then rate their goat’s athleticism on a 5-point scale:
- Below Average
- Better Than Average
But, Yagi! Can’t we simply use the script in part one?
Sure, you could. However, you might come across a bit of a problem. In Part 1 we generated our choices for our count based on their appearance in the survey. What happens if none of the respondents rated their goat as Weak (This is right and just)? Weak would not be recorded in our 2d count array when we ran our Google Apps Script code.
Further, if the first user in our Google Sheet response data rates their goat as Strong, then the first choice in our 2d count array will be Strong.
That would just look weird for a summary count of a rating survey. We really need to display our count in order from 1.Weak through to 5.Strong.