Google Spreadsheet – Letter Grade Calculator and Variables - google-sheets

Trying to create a letter grade calculator for personal use, however, I'm struggling with variables. "TOTAL" is the sum of all letter grades with their respective value. Please check the screenshot below.
Screenshot

Assuming the range with letters is in B23:B32 and the loopkup range is B24:E29, try in B33:
=SUM(ARRAYFORMULA(IFERROR(VLOOKUP(B23:B32, D24:E29, 2, 0))))
and see if that works?
EDIT: For you locale, you may have to change the comma's to semi colons.
=SUM(ARRAYFORMULA(IFERROR(VLOOKUP(B23:B32; D24:E29; 2; 0))))

Related

mapping vlookup for each element of splitted list in google sheets

This question is also answered here:
Get a vlookup of a cell after split in Google sheet
but not marked as corrected answer, and cannot make it work.
Goal : I want to apply a vlookup function to a split function, so that I can search for corresponding values (found by the vlookup) for each token obtained from a string.
Consider this sheets:
// Sheet 'veggies'
A
apple, pine, tree
pine
// Sheet 'themes':
A
B
C
apple
8
theme1,theme2
tree
3
theme2
pine
1
theme1,theme3
I want to:
split cells of column A of 'veggies' by commas, so to have tokens
vlookup for the C column in 'themes' sheet, by using the index of tokens, for all of them
As approach I tried to first retrieve the frequences of tokens in column B, sheet 'themes', and cannot understand what my formula is doing:
=ARRAYFORMULA( VLOOKUP( split(A2;",");'themes'!A$2:D;2;FALSE))
This formula only get the frequency from column be for the first token, while for others will only report N/A saying could not find a value, but it is clearly there.
Any help?
Am I on the right track ?
P.s. if one would like to offer use of query , like in the other SO answer, please help me to break down what it does.
ARRAYFORMULA( VLOOKUP( split(A2;",");'themes'!A$2:D;2;FALSE))
Your formula works. But when splitting by comma , there's a extra space left over in all the elements from the second element. So, when
apple, pine, tree is splitted, it becomes apple, pine, tree(note the extra space prefix). To fix, you can simply add a space to the split as well:
=ARRAYFORMULA( VLOOKUP( split(A2;", ");'themes'!A$2:D;2;FALSE))
this should work if you want the results in one cell.
=ARRAYFORMULA(TEXTJOIN(", ";TRUE;IFERROR(VLOOKUP(SPLIT(A2;", ";0);themes!A:C,2,0))))
Use this formual
=ArrayFormula(LAMBDA(v,
IF(v="",,{v,SPLIT(VLOOKUP(v,themes!A2:C,3,0), ", ",1)}))
(FLATTEN(IF(A2:A="",,SPLIT(A2:A, ", ", 1)))))

Can I use COUNTIF to count text strings in a range that exist within, or match, a single cell?

For this question I have made a simplifed example spreadsheet to illustrate what I am trying to achieve.
This can be found here.
https://docs.google.com/spreadsheets/d/1qbzuDHfRnGHkDhrcQWbQxRVcxsqo3MlJ3pZtU16nq7w/edit?usp=sharing
I will give background on the sheet first and then explain the problem, Forgive me if it's a bit convoluted it's my first time asking a question on here.
In the left hand side table I have example bank transactions made. In the right hand side table I have example data from my cash flow forecast. The goal is to match bank references and amounts to make sure that the forecast and the real transactions match up.
Actual Bank Transaction Table on Left Hand Side
Column A - Transaction references
Column B - Transaction amount
Column C - Formula to count the number of reference matches between the real transactions references in Column A and the forecast transactions reference range F3:F16
Column D - THIS IS THE PROBLEM I AM SEEKING A SOLUTION TO
Forecast Transactions on Right Hand Side
Column F - Forecast bank reference. (Either an exact match or a string contained within the string in Column A to allow for references that change every month i.e. Col A = "NETFLIX 23424589745897872134" and Col F = "NETFLIX")
Column G - Forecast transaction amount
The reason I am doing it with counting ref and price matches is that I then use these to automatically decide whether the transaction is a match to the forecast or not.
The problem is how to achieve my formula for Column D of my example spreadsheet. I need to check for price matches between each cell in column D and the range G3:G16 but only count matches where the transaction reference in column A matches to the range F3:F16 as per column C. This is to cut out many price matches that are not relevant.
The formula in C3 is currently
=if(A3="","",SUMPRODUCT(--ISNUMBER(SEARCH($F$3:$F$16,A3))*($F$3:$F$16<>"")))
This formula works great and is able to look at the range F3:F:16 and count both an exact match or strings contained within the string in Column A (i.e. Col A = "NETFLIX 23424589745897872134" and Col F = "NETFLIX"). This formula essentially allows me to count text strings in a range that exist within, or match, a single cell.
So at this point I cannot work out what the formula needs to be in Column D. I have tried to create a COUNTIFS formula with wildcards "" & & "" but I can't make anything work. My problem is that I can't utilise the current formula in Column C within a COUNTIFS in column D. Is there a way I can achieve the same outcome of Column C in a COUNTIF formula? Then I would be able to use that within a COUNTIFS formula in column D and my problem is solved... Hooray!
I know there must be a way but so far gogle has not been able to help me find the answer.
Please help!
Thank you :-)
in D3 try:
=INDEX(IFNA(VLOOKUP(REGEXEXTRACT(A3:A, TEXTJOIN("|", 1, F3:F)), F:G, 2, 0)))
update 1:
=INDEX(IF(A3:A="",,(B3:B=IFNA(VLOOKUP(REGEXEXTRACT(A3:A,
TEXTJOIN("|", 1, F3:F)), F:G, 2, 0)))*1))
update 2:
=INDEX(IF(A3:A="",,
IFNA(VLOOKUP(REGEXEXTRACT(A3:A, TEXTJOIN("|", 1, F3:F)), QUERY({F3:F},
"select Col1,count(Col1) group by Col1"), 2, ), 0)))

COUNTIFS w/ Multiple Criteria in Same Column

I'm trying to count instances of letters (like letters C through Z, excluding RR) within the same column if they are listed next to a name. Here's my sample Google Sheet that you can edit.
I'm trying to insert the formula in cell F3 that is highlighted yellow. So far I have...
=arrayformula(SUM(COUNTIFS(A2:A,{"C","D","E","F","G"},C2:C,E3:E)))
It seems like what I have should work, but it's giving me a #VALUE error, saying, "ARRAY arguments to COUNTIFS are of different size".
It seems like REGEXMATCH could be used inside the COUNTIF formula to make it easier to restrict the search to the range of letters I need, but not sure how to construct the formula.
Thanks for your help!
UPDATE
This formula below works but only for column A. I actually need to specify a different range of letters to be counted in column B and totaled in column K.
=QUERY(A2:C,"select C,count(A) where A matches 'C|D|E|F|G|H|I|J|K' group by C label count(A)''", 0)
Seems like this post almost answers it.
Current progress:
={QUERY(A2:C,"select C,count(A) where A matches 'C|D|E|F|G|H|I|J|K' and A is not null group by C label count(A)''", 0),QUERY(A2:C,"select count(B) where B matches 'F|G|H|I|J|K' and B is not null group by C label count(B)''", 0)}
As we have discussed / tested on your sample sheet. This should work as close as possible to the data that you would want to filter/display.
A 2-formula solution was found to work as well. Answer is in the same spreadsheet linked above in Sheet2. It should prevent the first formula from not working should someone need a different one.
J2 - =QUERY(A2:C,"select C,count(A) where A matches 'C|D|E|F|G|H|I|J|K' group by C label count(A)''", 0)
L2 - =ArrayFormula(IFNA(vlookup(J2:J,QUERY(A2:C,"select C,count(B) where B matches 'F|G|H|I|J|K' group by C label count(B)''", 0),2,0)))
This formula should work for you if you paste it in cells F3 to F7.
I currently have cells P1 to P26 (you'd probably want to hide this column) occupied with the letters of the alphabet in order, making it so that you can select P3:P26 (C-Z) to put into your first condition for your COUNTIFS.
=arrayformula(SUM(COUNTIFS(A2:A, $P$3:$P$26,C2:C,E3)))
You'll have to implement these formulas in the other places that you want them too, but it shouldn't be hard to change this formula to work in the other places as well.

Google Sheets: Sum if value is round number

I'm sure there's a pretty simple solution, but I cant' get to it.
I'm trying to sum a list of numbers, but only the values that are round numbers/whole integers.
Eg column A:
1
1.5
3
2.4
2
sum of the whole numbers
1 + 3 + 2 = 6
Any hint?
Let's suppose your numbers list begins in A2 and runs downward (i.e., A2:A). You can use this:
=SUM(FILTER(A2:A,A2:A=INT(A2:A)))
In plain English, this reads as follows: "Sum only those numbers in A2:A where the original value is the same as the integer-only portion of that value."
Try:
=sumproduct((A1:A5)*(A1:A5=int(A1:A5)))
this will also work in Excel
use dot detection:
=INDEX(SUM(IF(REGEXMATCH(""&A:A, "\."),,A:A)))
Another solution, you can use SEARCH to search for the decimal point:
=SUM(A1:A)-SUM(FILTER(A1:A,SEARCH(".",TO_TEXT(A1:A))))
or =SUM(FILTER(A1:A,NOT(ISNUMBER(SEARCH(".",A1:A)))))
as JvdV mentioned in his comment.
Either try QUERY():
=SUM(QUERY(A:A,"where A matches '\d+'"))
Or FILTER():
=SUM(FILTER(A:A,MOD(A:A,1)=0))
Note: This 1st option makes use of the possibility to use a regular expression inside the "where" clause of QUERY(). Use =SUM(QUERY(A:A,"where A matches '-?\d+'")) if you want to account for positive and negative integers.

How to sort in google sheets incrementally

Background
I'm making a spreadsheet that will plan out attendees for a wedding. There will be separate halls for men and women, and we are debating which age groups should be invited. Right now I got a tab i my sheet called age range and it has the following age ranges:
0 - 3
4 - 12
12 - 18
18+
I have a tab that has different families, along with their gender, age range etc listed like so:
here is the summary sheet:
Question
The goal of doing this spreadsheet is to be able to quickly make decisions like: do we want to invite everyone from family x/y/z with everyone above 12 years old etc?
What I would like to do in the spreadsheet, is if i select the dropdown of age group and select, say, 4-12, then i want everyone in the age group 4-12 (and the ones older) to be selected.. right now if i select 4-12, then only the people who are 4-12 years old get listed..
ideas?
(note: keep in mind i want the age group that is as equal or older.. not the other way around.. ie if the age group 18+ was selected, i don't want anyone younger than 18 to be included)
update
here is an editable copy of the spreadsheet
update 2 (what I tried)
I was able to do this for a single value: ie tell me if the person belonging to a specific cell in the heba_immediate_family table belongs to an age range group that is equal to or greater than the one you selected, by running this:
=match(vlookup(C23, 'age range'!$A1:$B4, 2),
{vlookup(heba_immediate_family!D2,'age range'!$A1:$B4,2)},1)
however I don't know how to expand this to include the whole table, ie this formula:
=ARRAYFORMULA(match(vlookup(C24, 'age range'!$A1:$B4, 2),vlookup(heba_immediate_family!D2:D19,'age range'!$A1:$B4,2),1))
returns this error
Did not find value '0' in MATCH evaluation.
ideas?
The use of MATCH in your second update was, indeed, the way to go, adding that inside the COUNTIFS that you started with. (Corrected for the first row of the ranges.)
=COUNTIFS(heba_immediate_family!C2:C, B11, heba_immediate_family!D2:D, C11)
As it is in the screen shot, the first criteria in your COUNTIFS is okay, so we'll start by rebuilding the second criteria. More specifically, what the range is matched against, which is shown as C11 in the sample. Because you need to create a cumulative selection rather than a single selection we need to compare the cell range against the age range using an inequality operator. With nothing given, the COUNTIFS implicitly defaults to = for comparisons. We need to change that to an explicit comparison using >=, greater than or equal, so that it matches anything in the selected range, or greater. This yields:
=COUNTIFS(heba_immediate_family!C2:C, B11, heba_immediate_family!D2:D, ">="&C11)
The next problem is that your case is using what is really a text string in what we think of as a numerical range. To fix that is where we need to use the MATCH function. MATCH returns the position of the matched item in the range relative to the start of the range. You have already prepared for this with the age range sheet, which we can use. We don't however need the second column since we're going to use the MATCH function rather than the VLOOKUP function. The numbers we will get from MATCH will, however, be the same as what's listed in the second column, so it does serve as a handy reference. To make this work, we need to use MATCH on both sides of the comparison so that we're getting the same reference point. The MATCH function normally works on one cell, so we also need the ARRAYFORMULA function to apply the first MATCH in an array sense. One last point is that the MATCH function defaults to assuming that the given range is sorted in ascending order. Since the age ranges are really text, they are not. We need to inform the function of this with the optional third argument set to 0, This now gives us:
=COUNTIFS(heba_immediate_family!C2:C, B11, ARRAYFORMULA(MATCH(heba_immediate_family!D2:D, 'age range'!A1:A, 0)), ">="&MATCH(C11, 'age range'!A1:A, 0))
If you want to type this in to each cell on the summary sheet, we're done. If you want to be able to replicate it by dragging, then we need to lock down some of the range references with absolute notation, $. This will give us:
=COUNTIFS(heba_immediate_family!C$2:C, B11, ARRAYFORMULA(MATCH(heba_immediate_family!D$2:D, 'age range'!A$1:A, 0)), ">="&MATCH(C11, 'age range'!A$1:A, 0))
One more thing we can do to make this all easier to use is to link the sheet names in the formula to the name in the first column. This step will require a change to how the sheets are named, or the way the families are named in the first column of the summary page, so that they are the same. In the first column of the summary sheet you have heba immediate family and it references the sheet named heba_immediate_family. Since typing the underscore is less natural than typing a space, I'd recommend renaming the sheets to remove the underscores, but any way that makes the two match will work. Having done that, the next part is to use the INDIRECT function to turn the text into a sheet reference. Actually, because of how it works, we will really need to turn that into a range reference using the text in the cell as part of it. The way we're going to do that is to concatenate the text in the cell with the fixed text of the range, like this for the age range column, INDIRECT(A3&"!D$2:D"). Doing that for both ranges, and moving it into the data first row of the summary sheet, gives the final version in cell D3, which can be reproduced down the sheet as needed for all the families. The completed formula is:
=COUNTIFS(INDIRECT(A3&"!C$2:C"), B3, ARRAYFORMULA(MATCH(INDIRECT(A3&"!D$2:D"), 'age range'!A$1:A, 0)), ">="&MATCH(C3, 'age range'!A$1:A, 0))
As a further option you could drop the gender column completely from the sheet. Everything in the top half is, by definition, "M", and in the bottom half is "F". So deleting column B moves the age ranges into column B and the formulas into column C. Doing that, and hard coding the gender into the formula gives two formulas.
For the Men, starting in cell C3:
=COUNTIFS(INDIRECT(A3&"!C$2:C"), "M", ARRAYFORMULA(MATCH(INDIRECT(A3&"!D$2:D"), 'age range'!A$1:A, 0)), ">="&MATCH(C3, 'age range'!A$1:A, 0))
For the Women, starting in cell C11:
=COUNTIFS(INDIRECT(A11&"!C$2:C"), "F", ARRAYFORMULA(MATCH(INDIRECT(A11&"!D$2:D"), 'age range'!A$1:A, 0)), ">="&MATCH(C11, 'age range'!A$1:A, 0))
And, since I see one final option that might be an improvement for use, I'll propose a final improvement, with an understanding. If the intention is to invite the same age range from all the families, rather than different ranges from each family, there is no need to have the age group selectable on each row of the summary sheet. Instead, make it a single cell at the top of the sheet and link all formulas to it. If, on the other hand, you are considering the option of different age ranges from different families, then this change is not what you would want to do.
To do this, combined with the last option about genders, again drop the column B of age group, moving the formulas, and totals, into column B. In cell D1 type "Age group:", and in cell E1 create the age range drop down. Then change the two formulas to these.
For the Men, starting in cell B3:
=COUNTIFS(INDIRECT(A3&"!C$2:C), "M", ARRAYFORMULA(MATCH(INDIRECT(A3&"!D$2:D"), 'age range'!A$1:A, 0)), ">="&MATCH($E$1, 'age range'!A$1:A, 0))
For the Women, starting in cell B11:
=COUNTIFS(INDIRECT(A11&"!C$2:C), "F", ARRAYFORMULA(MATCH(INDIRECT(A11&"!D$2:D"), 'age range'!A$1:A, 0)), ">="&MATCH($E$1, 'age range'!A$1:A, 0))
#abbood: The simplest way to handle this is to create an index for each demographic bucket you have (i.e. 4-12). Assign each a max value (i.e. 4-12 would be 12 because the maximum age of the attendant is 12). Assuming there are no gaps, then you can filter using this index value. You can use INDEX(MATCH()) or VLOOKUP() to use the index table alongside QUERY() or SUMIF() to aggregate or filter the table.

Resources