Reference value from row depending on value in another cell - arrays

I am looking to copy a cell value based on the correct value of another cell in that row.
Example:
On a Sheet 2 I have a dropdown with all values from column A1. I select the value Banana, I now want to also bring over the value Yellow from column B1 to be added to column B2.
Sheet 1:
Column A1
Column B1
Apple
Red
Banana
Yellow
Sheet 2:
Column A2
Column B2
Banana
?

use:
=VLOOKUP(A2; Sheet1!A:B; 2; 0)

Related

ISBLANK(...) = FALSE even thought the cell is blank in google sheet

Hi everyone,
I have 2 tables, 3rd column for Table 1 is Value 1 and 3rd column for Table 2 is Value 2. I combined these 2 tables by expanding both tables first so that all the columns are aligned as shown in the screenshot above (Column E to Column H).
The formula in all the yellow cells are:
Cell E4 : =QUERY(A4:C10,"Select A,B,C,' ' label ' ' 'Value 2' ")
Cell E12 : =QUERY(A12:C20,"Select A,B,' ',C label ' ' 'Value 1' ")
Cell K7 : =QUERY({E5:H10;E13:H17},"Select * where Col1 is not null",0)
Cell P7 : =ArrayFormula(IF(ISBLANK(M7:M12),100,M7:M12))
In column P, I want to return 100 as Value 1 if the cells in Column M is blank. So by right I should get 2,34,55,100,100,100 in column P but right now the formula still return 3 blank cells.
I suspect that is because the QUERY function that I used before which make the cell is not blank although it seems like still a blank cell. May I know is there any trick that I can use to find the blank cells in column M and column N (preferably don't touch the QUERY formula) since ISBLANK() is not working in this case?
Any help or advise will be greatly appreciated!
Edited
makes sense. you cant use ISBLANK because cell is not blank. remember that QUERY inserted an empty space.
try:
=ARRAYFORMULA(IF(ISBLANK(TRIM(M7:M12)), 100, M7:M12))
ISBLANK is so sensitive that it will detect even residue from TRIM
update:
=ARRAYFORMULA(IF(TRIM(M7:M12)="", 100, M7:M12))

If blank return 0 else run vlookup

I would like to use the vlookup function to match two criteria values firstly based on the value selected in a dropdown menu (country) and the value in A2(name). If the value in A2 Sheet matches the one of the values in the A column in Sheet2 and the value of the dropdown menu in Sheet1 matches one of the values in Sheet2 Column D (Which is a concatenation of the name and country) I would like to return the corresponding value in Sheet2 ColumnC.
If the value is 0 or blank I would like to return 0.
This is what I have tried
=ARRAYFORMULA(
IF(
ISBLANK(
IFERROR(VLOOKUP(A2&C2,Sheet2!$A$2:$E$61,3,1),"0"))))
Not sure what I might be doing wrong
Here is a sample of my data
Sheet 1:
A B C
name1 (vlookup) [dropdownmenu]
and Sheet 2
A B C
name1 val concatenationofA&B
Here is a test sheet as requested:
https://docs.google.com/spreadsheets/d/1jsFnaGY7N9nXyPs5vR32jG5G838w1SgB2XIad7bEFXg/edit?usp=sharing
try:
=ARRAYFORMULA(IFNA(VLOOKUP(A2:A&C2:C, {Sheet2!A2:A&Sheet2!B2:B, Sheet2!C2:C}, 2, 0), 0))
I managed to resolve this using the query function
=QUERY(Sheet2!$A$2:$E$61,"select C where B = """&C12&""" and A = """&A12&""" ")
The only problem is I don't know how to suppress NA values/replace them with the value 0

Distinct values from a field in vespa

I'm using vespa to view some data. Consider the following data
id product brand
1 a b1
2 b b1
3 c b1
4 d b2
5 e b3
I tried grouping to display the data from brand field. I had a field with price and I wrote a query like this
SELECT * FROM s_data where default contains "soap" | all(group(brand) each(output(sum(price))));
Basically, I don't want to calculate the sum of price, all I want is distinct values from the field 'brand'. Is there a way to do that in vespa?
all(group(brand) each(output(count())))
Gives you all the unique values of the brand field attribute along with their occurrences count. If you really don't need the count you can ignore it in the output.

How can multiple values in a cell be validated against multiple cells at once?

I'm trying to validate default selections for a user:
**Table 1** -- Displays values
Cell value = 1
Cell value = 2
Cell value = 3
Cell value = 4
Cell value = 5
**Table 2** -- Displays values selected by user
Cell value = 2, 4, 5
Is there a way to compare the values from multiple cells in Table 1 to the values listed in a single cell in Table 2?
Thank you.

EXCEL lookup an a row / array based on a cell value

I would like to look up a row (an array) based on the DATE value, such that an array of price value (instead of a single return if using VLOOKUP) is returned for a given DATE value. Below is the data
Column A Column B Column C Column D
Row1 DATE Product A Product B Product C
Row2 1/1/2017 1 5 7
Row3 7/1/2017 3 6 5
Row4 13/1/2017 2 8 3
Thank you in advance
So one way to do this would be to make the lookup row a relative value. So assuming that your sample data is on Sheet1 and the list of dates you are looking up against is on Sheet2 Col A with a header. I would first make the lookup range a named range so that Sheet1 Col A thru Col D is named something like "Data". Then in B2 place the below formula and copy it to over to Col D and then all the way down the list of dates.
=vlookup($A2,Data,Column(B1),False)
The $ for A2 allows it to always look at column A even when copying over the formula. The Column(B1) returns a value of 2 but when you copy that formula to the left it will change to Column(c1), Column(d1)... thus changing what column of data you want returned.

Resources