Convert text in a cell into a number - google-sheets

I'm creating a Google Form to make digital multiple choice tests. The answers that are given will be sent to Google Sheets. The answers are multiple choice so the data that I get consists of a limited number of possible answers.
In this spreadsheet I want to add points (like 3,3 or 5 or 10 or 0) to the answers that are given depending on whether the answer is correct (or partially correct).
In the example spreadsheet every row consists of all the answers that are given by the student. This is automatically imported like this when a student sends in the form (in this testfile I have only one question). In B30:B33 I have put the four answers the multiple choice test has for this one question and in an adjacent column the number of points each answer is worth. I want to connect the points to the answer that is given in D2 (which is a wrong answer and should result in 0).
How can I do this?

With enough responses your range of result scores is likely to get in the way where it is so I suggest moving it to another sheet and giving it a name, such as NamedRange1. But I would swap over the columns first (answers to the left of their scores) - and replacing the 0s to suit with 3,3 5 and 10.
Then in your form responses sheet Formulierreacties 1:
=vlookup(D2;NamedRange1;2;0)

Related

How do I format multiple free text columns into a single list on Google sheets but keep quantitative data tagged?

I want to group some columns into one list while keeping others as columns if possible. I have a sheet with quantitative data and also multiple qualitative free text answers. I've been asked to format the sheet so that the free text sits under the same column heading and has the quantitative data attached. Hopefully the images explain the desired format, is this possible?
Original format
Desired format
I tried the transpose formula, however its not what I need. I need the structure of table to stay the same and the free columns to sit in the same list. The quantitative data can duplicate.
My solution currently is to duplicate the sheet as many times as free text questions (i.e. 3 free text questions = 3 copies of the sheet). I keep 1 free text question on each sheet and rename that column the same on each sheet i.e. "All qualitative data". I then copy and paste the 3 tables under each other to create 1 table with 1 free text column.
Well simple solution is to just utilize the properties of arrays separated by a semicolon ;. This is essentially 3 different tables that are being stacked.
={QUERY(A1:F,"SELECT A,B,C,D WHERE A IS NOT NULL");QUERY(A2:F,"SELECT A,B,C,E WHERE A IS NOT NULL");QUERY(A2:F,"SELECT A,B,C,F WHERE A IS NOT NULL")}

Shuffle a deck of 7 hypothetical trading cards and list out the orders they can come in a Google Sheet [duplicate]

This question already has answers here:
How to list all permutations without repetition?
(2 answers)
Closed 5 months ago.
Say I have a set of seven unique trading cards and I want to shuffle them and list them out for all their possible permutations (pool of 7, taking 7). No card may be duplicated within each permutation of an arrangement as I have only one of each card, and I am not looking for the number of permutations available. I want the list itself.
How would I use one Google Sheets formula (no manual data entry on an iterative basis past the first line) to shuffle these cards: A, B, C, D, E, F, and G into a list of unique permutations per row? They can be arranged into a tidy list (ABCDEFG) within each cell or each card to a column, but along each permutation, there must only be one of each card (ABACDEF shouldn't exist).
I've looked everywhere to shuffle just one column of values into all possible ordered sets with no repeated objects per set. Still, I lack the remembered terminology to search for the right answer.
If you know about the solution, give me the link please.
https://webapps.stackexchange.com/questions/129778/is-there-a-formula-to-list-all-possible-2-card-combinations-of-4-playing-cards-i
Reducing the question to trading cards for this post inspired me to pose it that same way to Google, and I found this. I believe the above example may be scaled up to 7 in 7 cards.
Feel free to try coming up with a better answer... I noticed the formula in the above post is rather long. I'm looking for the most compact answer available.
EDIT: Aha! I think I found one better.
Generate all possible combinations for Columns(cross join or Cartesian product)
I was having issues running into the rept function's 32000 character limit. So, I added the lengthy transposition formula found here:
https://stackoverflow.com/a/73523983/4143583
Combining that formula within a query similar to the first link's answer but scaled up a bunch ("where Col1 <> Col2 and Col2 <> Col3", etc.) seems to have solved my issue with repeated members within each permutation.

Google Sheets removing duplicate data based on date and data

I apologize if I've overlooked any similar questions that have been answered regarding this issue. I spent a few hours looking through as many questions as I could, but none have gotten close to helping me resolve this particular problem...
I'm working with Google Sheets along with a form to help populate a chart that gives us the locations of equipment based on serial numbers (screenshots below).
The chart is arranged by building names that have the potential to house equipment in column A and equipment types in columns B-H. The form attached to this chart sends its submissions to a second sheet, which is where I draw the data from. I am using MAXIFS to populate the
The problem I'm having is that when a new form submission is entered into the second sheet regarding the movement of a piece of equipment that has previously been moved, the chart will list that equipment in two places instead of simply listing it in the newest location based on the newest form submission. Obviously an item can't be in two places at once.
chart sheet
form sheet
As you can see from the screenshots above, in the "chart sheet" it shows 9006 in three different locations. In the "form sheet" it shows that 9006 was moved from LSB to HSB and then to Admin (in column D).
What I'm looking to do is remove all previous submissions regarding a piece of equipment and only using the newest submission in the chart sheet so that it shows me that piece of equipment in only its newest location. I've tried using UNIQUE, FILTER, and QUERY to try to get the results I'm looking for, but to no avail.
Again, I apologize if a similar question has been answered previously. If any further information based on this question is needed, I'll gladly provide it. Thank you!
EDIT: Here is the "form sheet" with the properly spaced timestamp column.
form sheet2
EDIT 2: The equipment are labeled with similar serial numbers but are proceeded by different letters (ex: X9006 and B9006 have similar numbers but are separate pieces of equipment because of their preceding letters.) The serial numbers are listed in column C of the "form sheet" and the preceding letters are in column B of the "form sheet". The answer from player0 works wonderfully, but only considers the serial numbers without regard to the letters in column B. Some buildings may contain different pieces of equipment with the same serial numbers, but have different letters. I would like for the chart to have the ability to list the same serial number on the "chart sheet" only if the preceding letters are different. I hope this makes sense.
try:
=SORTN(SORT(A2:D; 1; 0); 9^9; 2; 3; 1)

How do I do a SUMPRODUCT in Google Sheets, but conditional on the text in both vectors?

The following spreadsheet shows the exercise submission status for 4 students. There are 4 exercises (1-4), but only 2 of them are homework (and thus graded) - they have a prefix 'H' in their name. A correct submission is marked "complete".
I'm trying to count, for each student, how many "complete" submissions he has, which are also homework. The right-most column is my desired result.
I tried all kinds of countifs, but couldn't get it. I have an ugly solution which uses SUMPRODUCT, but that requires substituting all the "complete" with 1's (which I'd rather not) + some more. I prefer a Google Sheets solution, but excel would work as well...
Have a heart and help out a teacher :-)
I suggest using mmult, which is a standard way of getting row totals from a matrix. As you mention, the first step is to convert each cell containing "complete" into a 1, then check the headers for presence of letter H.
=ArrayFormula(mmult((A2:D6="complete")*(isnumber(SEARCH("h",A1:D1))),transpose(column(A2:D6))^0))
I have tested this in Google Sheets, but it should work in Excel as well.
EDIT
(1) The easiest way to make the range accommodate changes is to put some upper limit on number of columns and make the references full-column, e.g.
=ArrayFormula(if(A2:A="","",mmult((A2:M="complete")*(isnumber(SEARCH("h",A1:M1))),transpose(column(A2:M))^0)))
You might want to move the total off onto another sheet:
=ArrayFormula(if(Sheet7!A2:A="","",mmult((Sheet7!A2:Z="complete")*(isnumber(SEARCH("h",Sheet7!A1:Z1))),transpose(column(Sheet7!A2:Z))^0)))
(2) To get the values as percentages, you can use countif:
=ArrayFormula(if(Sheet7!A2:A="","",mmult((Sheet7!A2:Z="complete")*(isnumber(SEARCH("h",Sheet7!A1:Z1))),transpose(column(Sheet7!A2:Z))^0)/countif(Sheet7!A1:Z1,"*h*")))
and format column as percent.
EDIT 2
To check for presence of H in headers but ignore h, use Find instead of Search, and regexmatch instead of countif:
=ArrayFormula(if(Sheet7!A2:A="","",mmult((Sheet7!A2:Z="complete")*(isnumber(find("H",Sheet7!A1:Z1))),transpose(column(Sheet7!A2:Z))^0)/sum(--regexmatch(""&Sheet7!A1:Z1,"H"))))
If you only want to include headers _starting_with H, change "H" in the regexmatch to "^H" as in #player0's answer.
if position of H columns is known, you can do simple:
=INDEX(IF(A2:A="",,ADD(D2:D="complete", E2:E="complete")))
if the number of columns and position of H's is unknown:
=INDEX(MMULT((INDIRECT("A2:"&ADDRESS(COUNTA($A:$A), COLUMN()-1))="complete")
*(REGEXMATCH(UPPER(INDIRECT("A1:"&ADDRESS(1, COLUMN()-1))), "^H.*")),
ROW(INDIRECT("A1:"&COLUMN()-1))^0))
update:
=INDEX(TEXT(MMULT((INDIRECT("A2:"&ADDRESS(COUNTA($A:$A), COLUMN()-1))="complete")
*(REGEXMATCH(UPPER(INDIRECT("A1:"&ADDRESS(1, COLUMN()-1))), "^H.*")),
ROW(INDIRECT("A1:"&COLUMN()-1))^0)/
SUM(1*REGEXMATCH(UPPER(INDIRECT("A1:"&ADDRESS(1, COLUMN()-1))), "^H.*")), "0.00%"))

using sum and countifs to get a percentage of 'yes'es across multiple columns by month and team - is there a simpler way?

I've been asked to create a summary for some google form responses, and though I have a working solution, I can't help but feel there must be a more elegant one.
The form collects data related to case checking - every month each team (there's 100+ teams) has to check a certain number of cases based on how many staff are in their team, and enter the results for each case they've checked in the google form. The team that have set this up want me to summarise the data by team, month, and section of the form (preliminary questions, case recording, outcomes, etc). There are 8 sections on the live form, ranging from 1-13 questions, all with Yes/No/NA/blank answers.
(honestly, it's not how I'd have approached setting all this up, but that is out of my hands!)
So they're essentially looking for a live monthly summary with team names down the side, section names along the top, and a %age completed that will keep up with entries as they come in (where we can also use importrange and query to pull the relevant bits into other google sheet summaries, as and when needed).
What I've currently got is this:
=iferror(sum(countifs('Form Responses'!$B:$B,$A3,'Form
Responses'!$F:$F,"Yes",'Form Responses'!$E:$E,">="&$B$1,'Form
Responses'!$E:$E,"<"&edate($B$1,1)),countifs('Form
Responses'!$B:$B,$A3,'Form Responses'!$G:$G,"Yes",'Form
Responses'!$E:$E,">="&$B$1,'Form
Responses'!$E:$E,"<"&edate($B$1,1)),countifs('Form
Responses'!$B:$B,$A3,'Form Responses'!$H:$H,"Yes",'Form
Responses'!$E:$E,">="&$B$1,'Form
Responses'!$E:$E,"<"&edate($B$1,1)),countifs('Form
Responses'!$B:$B,$A3,'Form Responses'!$I:$I,"Yes",'Form
Responses'!$E:$E,">="&$B$1,'Form
Responses'!$E:$E,"<"&edate($B$1,1)),countifs('Form
Responses'!$B:$B,$A3,'Form Responses'!$J:$J,"Yes",'Form
Responses'!$E:$E,">="&$B$1,'Form
Responses'!$E:$E,"<"&edate($B$1,1)),countifs('Form
Responses'!$B:$B,$A3,'Form Responses'!$K:$K,"Yes",'Form
Responses'!$E:$E,">="&$B$1,'Form
Responses'!$E:$E,"<"&edate($B$1,1)))/(countifs('Form
Responses'!$B:$B,$A3,'Form Responses'!$E:$E,">="&$B$1,'Form
Responses'!$E:$E,"<"&edate($B$1,1))*6),0)
It works, but it feels like a bit of a brute-force-and-ignorance solution. I've tried countifs & array, I've looked a pivot but I can't get the section groups, I've had a play with query but I can't figure out how to ask it to count all Yeses in multiple columns at once.
Is there a more elegant solution, or do I have to resign myself to setting up the next financial year's summaries like this?
Edit:
You can use plain array boolean multiplication to achieve the count, as trues are converted to 1s and false are converted to 0s:
=TO_PERCENT(ARRAYFORMULA(
SUM((f!F1:K="Yes")*(f!E1:E>=B1)*(f!E1:E<EDATE(B1,1))*(f!B:B=A3))/
SUM(6*(f!E1:E>=B1)*(f!E1:E<EDATE(B1,1))*(f!B:B=A3))
)
)
Renamed Form Responses to f
Numerator: SUM of
Question filter (f!F:K =Yes) and
Month filter (f!E:E is within month of B1) and
Team filter(B:B = A3)
Denominator: 6 times the SUM of
Month filter (f!E:E is within month of B1) and
Team filter(B:B = A3)
On this sample sheet that you provided you'll notice two new tabs. MK.Retab and MK.Summary.
On MK.Retab is a single formula in A2 that "re-tabulates" all of your survey data into a format that is much easier to analyze going forward. That tab can be "hidden" on your real project. It will continue to build the 6 column dataset forever. It would be a sort of "back end" sheet, only used to supply data to any further downstream analysis.
On MK.Summary is a single formula in cell A1 that Query's that dataset from MK.Retab and shows the percentage of Yes's by month by section by team in a format similar to what you proposed. I coded it to display the most recent month at the left, immediately to the right of the team names, and to push historical data off to the right. Even though people are often used to seeing time go from left to right, I find that the opposite method nice because it keeps you from having to scroll sideways to see the most recent data. It is very simple to change should you want to by getting rid of the "desc" that you find in the "order by" clause of the query string.
I find this kind of two step solution to problems like your useful, because while the summary migth not be exactly what you want, it's always easier to build formulas and analyses off of the data as laid out in the MK.Retab sheet.
As for the formula in MK.Retab, it is based on a method that I came up with a while back that constructs a large vlookup where the [search key] is actually a sequence of decimal numbers that is built by counting the number of rows in your real data set and multiplying by the number of columns of data that need to be repeated for each row. I built a demo some time ago that I'm happy to share with folks if you want to understand better how it works.
You said that your goal was to understand the formulas so that you could modify them going forward as needed. I'm not sure how easy that will be to do, but I can try my best to answer any questions you might have about the method or the solution generally.
What I can tell you is that some of the formulas are more complicated than they need to be because you just used Q1 Q2 Q3 etc instead of the actual questions. if you had a list of the questions asked somewhere (on some other tab, say), and what you wanted to call/name their corresponding "sections", it would make the formula significantly less complicated. As it stands, I had to use the appearance of the word "Comments", in row 1 to distinguish between where one section ended and another section began. The upside to that decision though, is that the formula I wrote is infinitely expandable to the right. That is, if you were to add another 100 columns worth of questions and answers to the sample set here, the formula would be able to handle that and break it out, so long as there was the word "Comments" between each section.
Hope all this helps.

Resources