LOOKUP always selects the last number in the column - google-sheets

I Have a list of 40 numbers similar to below
+-----------+------------+
| J | T |
+-----------+------------+
| 1 | 123.4 |
+-----------+------------+
| 2 | 223.8 |
+-----------+------------+
| 3 | 23.4 |
+-----------+------------+
| 4 | 443.9 |
+-----------+------------+
| 5 | 143.5 |
+-----------+------------+
So I want to look up a number in the first column based on the second.
So I am using the following formula (actual sheet has 40 numbers) =LOOKUP(23.4,$T$43:$T$82,$J$43:$J$82) in this example I would have expected the result to 3 but it is always 5 (40 in the actual sheet).
Where am I going wrong?

let use VLOOKUP() instead
=VLOOKUP(23.4,{$T$43:$T$82,$J$43:$J$82},2,FALSE)
because LOOKUP() doesn't have the option or the argument for exact match
I hope it'll work for you

Or use Index/match:
=index($J$43:$J$82,match(23.4,$T$43:$T$82,0))

Related

Create column taking number of values from one column and actual value from another column

I have two columns, A and B, where A contains the number of values for corresponding value in B. I want to create column C that contains the number of values from A but with the value from B. So for example:
| A | | B |
| 2 | | 40 |
| 3 | | 60 |
Should produce:
| C |
| 40 |
| 40 |
| 60 |
| 60 |
| 60 |
So 2 of 40 and 3 of 60. This could be in memory (I only want to use C in a formula, don't really need it as an actual column) or as its own column.
Give a try on below formula-
=ArrayFormula(TRANSPOSE(SPLIT(TEXTJOIN("#",TRUE,REPT(B1:B2&"#",A1:A2)),"#")))

How to forecast (or any other function) in Google Sheets with only one cell of data?

My sheet:
+---------+-----------+---------+---------+-----------+
| product | value 1 | value 2 | value 3 | value 4 |
+---------+-----------+---------+---------+-----------+
| name 1 | 700,000 | 500 | 10,000 | 2,000,000 |
+---------+-----------+---------+---------+-----------+
| name 2 | 200,000 | 800 | 20,000 | ? |
+---------+-----------+---------+---------+-----------+
| name 3 | 100,000 | 150 | 6,000 | ? |
+---------+-----------+---------+---------+-----------+
| name 4 | 1,000,000 | 1,000 | 25,000 | ? |
+---------+-----------+---------+---------+-----------+
| name 5 | 2,000,000 | 1,500 | 30,000 | ? |
+---------+-----------+---------+---------+-----------+
| name 6 | 2,500,000 | 3,000 | 65,000 | ? |
+---------+-----------+---------+---------+-----------+
| name 7 | 300,000 | 300 | 12,000 | ? |
+---------+-----------+---------+---------+-----------+
| name 8 | 350,000 | 200 | 9,000 | ? |
+---------+-----------+---------+---------+-----------+
| name 9 | 900,000 | 1,200 | 28,000 | ? |
+---------+-----------+---------+---------+-----------+
| name 10 | 150,000 | 100 | 5,000 | ? |
+---------+-----------+---------+---------+-----------+
What I am attempting is to predict the empty columns based on the data that I do have. Maybe just one of the columns that contain data in every row or maybe I should be only focusing on one column that contains data in every row?
I have used FORECAST previously but had more data in the column that I was predicting values for which the lack of data I think is my root problem(?). Not sure if FORECAST is best for this so any recommendations for other functions are most welcome.
The last thing I can add though is that the known value in column E (value 4) is a confident number and ideally it's used in any formula that I end up with (although I am open to any other recommendations).
The formula I was using:
=FORECAST(D3,E2,$D$2:$D$11)
I don't think this is possible without more information. If you think about it, Value 4 can be a constant (always 2,000,000), be dependent on only one other value (say 200 times value 3), or be a complex formula (say add values 1, 2, and 3 with a constant). Each of these 3 models agree with the values for name 1, however they generate vastly different value 4 predictions.
In the case of name 2, the models would output the following for value 4:
Constant: 2,000,000
Value 3: 8,000,000
Sum: 2,489,700
Each of those values could be valid without providing further constraints (either through data points or specifying the kind of model, but probably both).

Automated way to create a confusion matrix in Google Sheets?

I have a table of this form in Google Sheets:
+---------+------------+--------+
| item_id | prediction | actual |
+---------+------------+--------+
| 1 | 1 | 1 |
| 2 | 1 | 1 |
| 3 | 1 | 0 |
| 4 | 0 | 1 |
| 5 | 0 | 0 |
| 6 | 1 | 1 |
+---------+------------+--------+
And I'd like to know if there's an automated way to get this kind of summary, with the counts of items that fit the criteria specified in that row/column combination:
+----------+--------------+--------------+-------+
| | prediction=0 | prediction=1 | total |
+----------+--------------+--------------+-------+
| actual=0 | 1 | 1 | 2 |
| actual=1 | 1 | 3 | 4 |
+----------+--------------+--------------+-------+
| total | 2 | 4 | |
+----------+--------------+--------------+-------+
I've been doing this somewhat manually in Google Sheets by using COUNTIFS, but I'm wondering if there's a built-in way? I tried using pivot tables, but couldn't figure out how to get the calculated fields to show the data I want.
A coworker figured it out - you can get this by creating a pivot table with the correct columns and rows, and setting the value to item_id summarized by COUNTUNIQUE.

How to add the content of a certain number of rows just below the VLookup output (Google spreadsheet)?

For instance:
________A_____|__B__|__C__|
1 | Mouse | 1 | a |
2 | Keyboard | 2 | e |
3 | Headset | 3 | i |
4 | HDD | 4 | o |
=Arrayformula(VLOOKUP("Mouse",A1:C4,{2,3},FALSE) --would return "1" & "a".
Is there a way to make it return the content of 1 row below as well, that "2" & "e" along with "1" & "a"? i.e., the desired final output should look like :
________C_____|__D__|__E__|
1 | | 1 | a |
2 | | 2 | e |
Thanx!
Try offset:
=OFFSET(A1,MATCH("Mouse",A:A,0)-1,1,2,2)
Offset in Google sheets is an arrayformula, so it can return multiple rows and columns.
Match function gives the number of row with matched name.

Coloring cells based on numbers in string

In my sheet, on column A I have a string of numbers divided by commas. Then there are 12 numbered columns, each with its own hour. How can I shade the cells if their column's number is listed in column A?
Here is an example of what I am hoping to achieve.
| A | B | C | D | E
1 | | 1 | 2 | 3 | 4
2 | 1,2,4 | (shaded) | (shaded) | | (shaded)
3 | 2,3 | | (shaded) | (shaded) |
Select the whole range
Apply conditional fofmatting
select custom formula: =MATCH(B$1,SPLIT($A2,","),0)>0

Resources