Consolidate response data from Google Form submissions where the respondents have the same name - google-apps-script

I thought I could figure this out, but it seems I can't. Basically, students' information will be input to Google Sheets through Google Forms, but due to my Google Forms having sections, the data of one student appears in different rows. Each student rates 4 subjects, and they each have 4 teachers; the form separates each subject area into sections and Google Sheets places this info into 4 different rows.
I'm trying to consolidate all the data that has an identical name into one row, rather than appearing in 4 different rows. I've recreated what my data currently looks like in this example spreadsheet.
Any help would be much appreciated, this is driving me mental!

You could do it with a lot of VLOOKUP's.
Suppose you put the list of names in A21:A24
=unique(C2:C11)
Then do a lookup on each Name/subject pair in the appropriate column
=ArrayFormula(iferror(vlookup(A21:A24&{"Math","Math","English","English","Science","Science","HSIE","HSIE"},{C2:C11&D2:D11,E2:N11},{2,3,4,5,6,7,8,9},false),""))
Explanation
Maybe the way to explain it is to build it up from the case of one student - one subject to many students - many subjects? This assumes that you've got a list of student's names in A21:A24 and you want to pull out the info for each of them from the original data.
(1) One student, one subject
Hopefully trivial - just provide a reference to the student's report
=E2
(2) Several students, one subject (maths) (Names not necessarily in same order as original list)
Use vlookup to get report against each name
=ArrayFormula(vlookup(a21:a24,C2:E11,3,false))
It's an array formula so that it works through each of the 4 names, finding the first report associated with each. Note that it would pick up a blank for Susan in your data, because the first row with Susan in it contains a blank for maths.
(3) Several students, several subjects
=ArrayFormula(iferror(vlookup(A21:A24&{"Math","Math","English","English","Science","Science","HSIE","HSIE"},{C2:C11&D2:D11,E2:N11},{2,3,4,5,6,7,8,9},false),""))
So here it's looking up pairs like
BobMath BobMath BobEnglish BobEnglish...JimMath JimMath JimEnglish...
(student name + first pair of curly brackets)
in an array (second pair of curly brackets) where the first column is
BobMath
JimMath
SusanScience
...
and pulling out the correct row. It's also got to tell vlookup what column to look in (third pair of curly brackets).
So the first vlookup generated by this would be
vlookup("BobMath",array,2,false)
where array contains
BobMath Cross (several other columns)...
JimMath Blue (several other columns)...
...
BillHSIE (several other columns)... Hair
so it would pick up Cross
and the last vlookup would be
vlookup(BillHSIE,array,9,false)
which would pick up Hair.
Now it doesn't pick up a blank for Susan's maths because the first row it looks in is row 9 and it picks up Tickle from column E.
EDIT
If you then wanted to add some columns which only related to the student and not to any particular subject (like 'student attends counselling') you would need a different approach.
=ARRAYFORMULA(IFERROR(VLOOKUP($A21:$A24,FILTER({$C2:$C11,M2:M11},M2:M11<>""),2,FALSE),""))
This does a lookup as in (2) above but first skips any cells which are blank in the particular column being used for lookup. This formula only works on a single column, but can be pulled across for additional columns.

Related

How to count a range of values in datastudio

I am trying to transform a report that I have made in sheets into the newest datastudio tool. In my sheet, I have a table where there are several columns that holds data related (this is because each row could have more than one value so I used the "split text into columns" function to represent).
What I have is something similar to:
ID
Component
Component 1
Component 2
101
wood
metal
gold
102
metal
copper
103
wood
gold
metal
In my excel, I have a formula to count the time a certain component is shown by using =COUNTIF(<range>,<string>)
Therefore, with the above formula, I have something similar to:
Component
count
wood
2
metal
3
copper
1
gold
2
I want to be able to build the same in datastudio. Turns out that since the components are divided into columns, I can only use one dimension and the result only shows the count of the first column.
I want to know if there is an easy way to accomplish this. My original data source is like this:
ID
Component
101
wood;metal;gold
102
meta;copper
103
wood;gold;metal
Maybe it's easier to work directly with the previous format but again, using the component in this case only counts for the first occurrence and not across the whole string.
For now, the only solution I can think of is splitting the text into rows instead of columns, but that is not feasible achievable using Google Sheets, or at least not that I am aware of.
Could somebody have an idea of how to accomplish this?
Thanks!
Edit
I am adding here the minimal reproducible example. This is the spreadsheet that I have (example) and the current report I am using so far (built-in sheets):
Now, I want to have the same report (plus more things) using datastudio. This is the report example I have in data studio. As you will see the record count for components is not accurate in DataStudio.
Here is a preliminary answer. I'll polish if we like it and delete it otherwise.
Consider the following sheet:
Range A2:B4 contains my data of interest. Rows 7:10 show the results I think you are looking for. The mechanism for creating this is the value of cell A6 which contains:
=ARRAYFORMULA(QUERY(FLATTEN(SPLIT(B2:B4,";")), "SELECT Col1, COUNT(Col1) WHERE Col1 is not null GROUP BY Col1"))
At the highest level, the formula splits each of the delimited text items into their own cell and then flattens all these cells into one column against which we then run a SQL query against the sheet to group and count them.

School Detention Tracker in Google Sheets

I am trying to make a spreadsheet for the Deans at my school to track student detentions. They aren't that great with technology so I want to make it as simple for them to use as possible.
Here is a link to the current layout: https://docs.google.com/spreadsheets/d/1FIW0QAWGStgdUmYU0rWAceWI-YvjM1RIIC_KC2OeWWI/edit#gid=0
It would have a row for every student in the school and use different columns to record when students received a detention and whether or not it has been served yet. I created a formula to check how many unserved detentions each student has so that the deans can easily sort for who needs to serve detention that day.
I want some help creating two scripts:
A button that the deans can click to assign a student a detention. It would need to find the next available empty cell on that row, input the current date, then find the next available empty cell and write "Issued"
A button that the deans can click to mark that student's detentions as served. It would need to find and replace all instances of the word "Issued" on that row with "Served"
Ideal dean workflow:
Issuing a detention - Find the student on the list and click the "Issue" detention button
Running detention - Find the student on the list and click the "Served" button
Meeting with a parent/looking over records later in the year - Find student on the list and scroll horizontally to view dates of all detentions earned that year.
Potential snags:
One of our deans already sheared a spreadsheet trying to sort it. Is there a way I can reduce this risk while still giving him the ability to sort by student name and number of unserved detentions as neccesary?
Here are a few workarounds in lieu of a macro:
To input date > ctrl + semicolon, or command + semicolon on macs. This will enter the current date in the cell.
Use the =countif formula to keep an easily sortable tally on number of detentions a student has been assigned and served
An if statement can let you know that, if the total count assigned vs. total count served do not match, then a student still has a pending detention.
I also recommend keeping a "viewer" tab that your dean uses and the actual area where people are recording the data separate. That way the dean can sort and manipulate your data without actually affecting the original entries.

How to create a dynamic table in Excel?

I am trying to create a dynamic table - I have tried a Pivot Table, but cannot get it to work. So I thought that maybe it could be done with an IF-statement, but that did not work for me neither.
Basically, I have 2 tables, 1 table containing the information (data source table) and 1 table that should be dynamic according to the data in the first table.
So if I change the data in the E-column, the Fruit table (image below) must be updated accordingly.
So if I write 2 instead of 1 in the count of Apples, then it should create 2 apples under the "Fruit"-column". Data in the remaining columns will be calculated with a formula/fixed data - so that is not important.
I am open to any solutions; formulas, pivot tables, VBA, etc.
Have a nice weekend.
I have both Excel 2010 and 2013.
If you want to repeat some text a number of times you can use a somewhat complicated formula to do it. It relies on there not being duplicate entries in the Fruits table and no entries with 0 count.
Picture of ranges and results
Formulas involved include a starter cell E2 and a repeating entry E3 and copied down. These are actually normal formulas, no array required. Note that I have created a Table for the data which allows me to use named fields to get the whole column.
E2 = INDEX(Table1[Fruits],1)
E3 = IF(
INDEX(Table1[Count],MATCH(E2,Table1[Fruits],0))>COUNTIF($E$2:E2,E2),
E2,
INDEX(Table1[Fruits],MATCH(E2,Table1[Fruits],0)+1))
How it works
This formula relies on checking the number of entries above the current one and comparing to the desired count. Some notes:
The starter cell is needed to get the first result.
After the first cell, it counts how often the value above appears in the total list. This is compared to the desired count. If less than desired, it will repeat the value from above. If greater, it will go to the next item in the list. There is a dual relative/absolute reference in here to count cells above.
Since it goes to the next item in the list, don't put a 0 for a count or it will get included once.
You can copy this down for as many cells as you want. It will #REF! when it runs out of data. You can wrap in an IFERROR(..., "") to make these display pretty.
If the non-0 rule is too much, it can probably be removed with a little effort. If there are duplicates, that will be much harder to deal with.

SSRS sub report?

I have a weekly report that is pretty basic.
Engineer, Account number, Name, Date etc.
The twist that I am not sure how to accomplish is that the user needs to see a list of attachments based on the above criteria. I have a query which creates a single row for each attachment.
The layout I am looking is per the attached image. What I need to do is take the Attachment Name and create a row for each attachment under the existing tablix based on all of the other columns. Basically what is happening is that for each SIOA name, multiple attachments are being created. I just need to see them listed below for each occurrence. I hope this makes some sense.
Since I cannot post the image, I have a basic tablix with 11 columns. One of the columns is Attachment. I need the attachments grouped as separate rows below the other 10 columns. This way the user will see only one row for each project and multiple rows of the attachments.
If I'm understanding correctly, I think the simplest solution is to make a new row group based on the Account# (or whatever unique ID you may have for each record). Then put all your fields except the attachment field at the group level, and leave only the attachment field at the details level. That way you will get one row per group, with all the attachment rows listed beneath that group. More information on creating row groups here. You could also get fancy with a drilldown action if you wanted to.

Extracting Values from 300 sheets where vlookup doesn't work

I have an excel spreadsheet which has just under 300 sheets in it. The first sheet has a list of items which are all numbered 1.1.1, 1.1.2 etc. The rest of the sheets have some of the items listed on them and not in numerical order. I am trying to extract the quantity and total listed against these items on all the different sheets.
The sheets are complicated by the fact that they are not well structure so have section titles which are across merged cells.
I could get this information by hand using the search facility in excel and visit each instance of the number and then add up all the quantities and totals by hand. Is there any way I can automate this? i.e. by asking excel to take each unique identifier from sheet 1, find it in the rest of the sheets and return the quantity and/or total?
I tried using vlookup but it only seemed to return one of the values and ignore all the others.
Even if there was a formula that I had to change the unique identifier by hand that would be much quicker!
Thank you for any help you can give. I am not a programmer so constructing the vb by myself would probably take longer than doing it by hand!
If you add a $ before your lookup data for example
search - $A&2:&AZ&1000
then you are telling excel to look for anything in that array.
because if you do not have a $ in and you copy it, it starts excluding everything above that.