Multiple Criteria - vlookup - google-sheets

I have been trying to use an If(and... to grab a lookup if the weight (column F) meets the range on a second sheet between the min and max columns.
For example: If a SKU's weight is between a highsize and a low size on sheet 2 and the helper column matches, then I'd like to pull in the price.
Link: https://docs.google.com/spreadsheets/d/1ermKIQnZRcWzm8ogDE7IK0fQSLohDsOBHuaUjjRi8io/edit?usp=sharing
The helper column is a join of the shape, color, and clarity, however, the carat weight will then decide what the standard industry price for that goes.
Multiple SKUs can have the same shape, color, and clarity so the weight would be the defining factor. I created helper columns to help with that part, however, I am having trouble getting a formula that would combine a lookup and an if weight is >highsize and <lowsize.
The main project I'm working on has many, many, skus so going through each one and copying is not a viable solution. The second part is that the second sheet's prices will update on a weekly basis so I need to be able to update it to populate on the first sheet.

try in P1 cell:
={"E-Price"; INDEX(IFNA(VLOOKUP(B2:B, 'e-Price Ranges'!A2:G, 7, 0)))}

Related

Google Sheets vectorized operations

I have a Google sheet with a column of dates and numbers. What I want to be able to do is say: If the date is earlier than 9/1/2021, take the number and multiply by 1, otherwise multiply by 2, then sum all the products. The date and number columns keep getting new information as time goes on.
Now I know that I could create a kind of "scratch-work" column where I have a cell containing =IF(DATEVALUE(A1)<DATEVALUE("2021-9-1"),1,2) * B1 and then apply this formula to the column, and then sum the column somewhere else. However, this is not ideal because every time a new date and number come in I have to reapply the formula to the new scratch-work column's cell.
What I was hoping for was some kind of vectorized operator that would eliminate the need for the scratch work column in the first place. Something like being able to multiply whole columns like =B1:B * 2 or what is more appropriate for my current task, =IF(DATEVALUE(A1:A)<DATEVALUE("2021-9-1"),1,2) * B1:B.
I know you can do this kind of thing in R but haven't seen any vectorized operations in Google Sheets. I'm guessing it's not possible but wanted to ask just in case.
=arrayformula(if(A1:A="","",IF(DATEVALUE(A1:A)<DATEVALUE("2021-9-1"),1,2) * B1:B))

Conditional Median combining different values in Google Sheet Formula

Is there a way to calculate the Median of a set of values in one column depending on whether the adjacent column contains a value that is within a set of values?
Below is a table sample:
I would like to get the median of all the Revenues from the US (combine Team US East and West).
First you have to filter this table according to your criteria and then extract median from new range.
Filtering may be obtained using QUERY function, and then you use built in MEDIAN formula.
I've prepared my example which uses two conditions - like yours.
=median(query(B2:C11,"select B where C ='a' or C='b'"))
I think the easiest way is with Filter and Regexmatch:
=median(filter(B2:B,regexmatch(C2:C,"^Team US")))
or in case there are more teams like Team US North and you don't want to include them:
=median(filter(B2:B,regexmatch(C2:C,"^Team US East|^Team US West")))

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%"))

How to Sum lots of IF results, where SUMIF and SUMIFS cannot be used

Have a sheet with items which have data attributes, and may be used for multiple purposes.
There is a lookup table to lookup a score, based on the attributes.
So I can get the score for each item, see the top right section, and then sum that for each of the purposes. So purpose 1 has 11 data attribute points etc.
The score formula is included in the image for reference.
However, rather than copy all the data and score it, ideally would like a formula that can just go into a scoring column. Otherwise, with say 200 items, I need to have 201 columns just to score this one thing...
However, sumifs and sumif won't do this. What I really want is a "sum(foreach cell in range, do this formula)"
Does anyone know how this might be done?
Just on this mini example, you could use
=ArrayFormula(sum(if(C4:E4="yes",vlookup(C$2:E$2,$B$9:$D$11,match(C$3:E$3,$C$8:$D$8,0)+1,false))))
so you do a lookup on attribute 2 to find which column to do the lookup on attribute 1.

Filter Data Based on Column Selection

Working in Google Sheets I'm making a gradebook. In the gradebook there are different assignment types that have different weights which can be chosen from the drop down. I would like to...
Average like assignment (there will be 3 values)
Weigh them appropriately (0.1 for baseline, 0.7 for Critical, 0.2 for accelerated.)
Add all the values together into 1 grade percentage.
Display them on grade report sheet for appropriate student.
I would like for this to be dynamic, so that if I change the assignment type (or any other values) the grade will change appropriately.
my MWE can be found here.
The AverageIf function will do what you need. So code like:
=averageif(B$3:G$3,"Baseline",B4:G4)
sitting next to your student in the 4th row (this is draggable, so row will update) that checks against values of assignment type in your 3rd row (3 is fixed by the dollar sign, so draggable) will accomplish your goal 1.
Once you do that for each of the averages, you can define one more column as =0.1*baseline avg+0.7*critical+0.2*accelerated
[not exactly that, I am pseudocoding] to achieve your other 3 objectives, I think.

Resources