Horizontal lookup using unstructured lookup keys - google-sheets

I need to find the rate for a given location and weight, using a lookup table that lists rates per location and weight. The problem is that the weights in the table are formatted like Up to 2 kg, 2.01-3 kg, 3.01-5 kg and so on, while the weights I am looking for are plain numbers like 10.5 and 13.5. How can I map the location-weight tuples to the rates in the lookup table?
Spreadsheet here

I am assuming that you want to obtain something like this:
where you input a location in the A9 cell and a Weight in the B9 cell and it automatically puts the correct rate in the C9 cell. This can be achieved with the following formula (in the C9 cell):
=ARRAYFORMULA(VLOOKUP(A9,A1:G5,HLOOKUP(B9,{A1:G1;COLUMN(A1:G1)},2,0),0))
which mixes VLOOKUP (you can read more about it here) to fetch the correct Location Code with HLOOKUP (you can read more about it here) to fetch the correct Weight.

This can be done very simply by just nesting one FILTER inside another; as per the answer given by Oriel Castander you could use this formula in cell C9 instead:
=filter(filter(B2:G5,A2:A5=A9),B1:G1=B9)

Related

Is there a formula that will search through multiple columns based on a search key?

The current formula is:
=averageifs(index(data,,match(B5,Headers,)),index(data,,match("position 1",Headers,)),B3)
The function averages total weight for specific positions. It goes through my data sheet's headers to find the column titled "position 1" to find all the athlete who play position B3, but I have athlete who play multiple positions and want to have them included as well.
Is it possible to get it to search through multiple column to find all the athletes who play the same position?
Headers named range
data named range
This gets a bit complex, but I think it will give you what you need. It does change the formula from the AVERAGEIFS to the QUERY function.
=QUERY(data,"select avg("&LEFT(ADDRESS(Headers,MATCH(B5,Headers,0),4),1)&") where C='"&B3&"' or D='"&B3&"' or E='"&B3&"' or F='"&B3&"' or G='"&B3&"' or H='"&B3&"' or I='"&B3&"' or J='"&B3&"' or K='"&B3&"' or L='"&B3&"' or M='"&B3&"' label avg("&LEFT(ADDRESS(Headers,MATCH(B5,Headers,0),4),1)&") ''")
I believe the only thing you may need to change is deleting some of the comparisons to columns. I wasn't quite sure how many Position columns you have in your original sheet.

I would like that a numeric list indicate movement when a value in the same row changes to another

An example of what im asking for
Im asking if there's a way to "mark" in the B column when a value changes in position respect at the C column.
Like if new data came and the EXAMPLE1 changes to the C8 cell, that the number in the B8 column show that it has a lower position.
Sheet : https://docs.google.com/spreadsheets/d/1pLYqhkLuAS8ZgjPnsZTZyU5yuPXVgm0IRUPIF2FBKkM/edit?usp=sharing
Google Sheets are better formulated in numeric value. In view with your screenshot provided, I saw player, and I assumed your player comes with various other numerical value along such as scores, age, weight, etc.
With the aid of the numerical value, you can formulate a deductive relation by finding who is best ranked number 1.
Here's an example:
As you can see from the picture above, assumed the greater the age, the higher the rank, you may use countif to count the other bigger value, while you can combine use count for deduction, and that builds the sequence from getting number 1 the older, and last the younger
Hope you find it helpful

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 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.

Calculating Distance Away from a Set Number (Google Sheets)

This is for Google Sheets or I could also write a script for it.
I am a teacher and am trying to create a formula or function that will calculate the distance a range of test scores are away from a set number (70 -- a passing grade).
I have my data in a column as a variety of percentages. I would like the formula or function to first check the range for any values that are less than 70. Then, for the values that are less than 70 it would figure out how far each of those values are from 70 and add them all together. Finally, it will take the sum of the added values and divide by the number of values that fit the criteria (less than 70).
Any ideas on how I would accomplish this? Thanks!
There are numerous formulas you can use: sumif, countif, and averageif
But if you want a dashboard-like spreadsheet that gives you quick summaries, filter is very useful.
Here is an examples of using filters
In particular, the formula is =average(arrayformula(filter(B2:B10,B2:B10<70)-70)), where
filter(B2:B10,B2:B10<70) gives you B values that are < 70
filter(…) - 70 finds the difference
arrayformula(…) is needed because you are working with an array
average(arrayformula(…)) finds the average of the array

Resources