Filter column with condition Google Sheets - google-sheets

I'm using Filter function using Google Sheets but can't use it the way I want, it has been 3 days...
Basically I have Sheet 1 with a column "e-mail" and column "Lead ID". The Sheet 2 has the same "Lead ID", but it's filtered. Meaning, Sheet 1 it' sequential with 1,2,3,4,5...and sheet 2 it's not, it's like 2,4,5,23,41... What I want to to find the right e-mail address that's in Sheet 1, that has the same Lead ID in both. I've used Filter function which works really well because it updated the rows and I dont need to drag the cell. But in this case this is not working:
ABD!C:C it's the E-mail Column.
ABD!T:T it's the Lead ID Column Sheet 1
A:A It's Lead ID Column Sheet 2.
=FILTER(ABD!C:C,ABD!T:T=A:A)
It returns the name of the column (e-mail) and not the actual e-mail address. If I use A2 instead of the column A:A, it works. But I can't use that way because I need to drag that cell and that causes a problem. I need to use this as the filter works which doesn't require to drag the cell.
=FILTER(ABD!C:C,ABD!T:T=A2)
https://docs.google.com/spreadsheets/d/1MKXCAc1-d8OU008OEHI2Tu7AObvaOueUD30jl5iG6W8/edit?usp=sharing
Any advice?

use:
=ARRAYFORMULA(IFNA(VLOOKUP(A2:A, {ABD!T:T, ABD!B:B}, 2, 0)))

Related

How to update data in a Google sheet depending upon another sheet?

I need to update a cell with a defined value automatically by comparing and referencing this data from another Google sheet.
In Sheet1 Column_C is to be updated by comparing Column_A in Sheet1 to Column_A in Sheet2.
If it is a match, and Column_B's value from Sheet2 is 1, then the result should be "issued", otherwise it should be "in-stock".
Sharing google sheet link :
https://docs.google.com/spreadsheets/d/1h_D5u16ye1CA6C7dideJVZoV8cBvZB8M3RRxXBANsf4/edit?usp=sharing
How can I accomplish this using Google Sheets?
Try this in cell C1 (delete all other values below):
=arrayformula({"Status";if(A2:A<>"",substitute(substitute(iferror(vlookup(A2:A,filter(sheet2!A:B,countifs(sheet2!A:A,sheet2!A:A,row(sheet2!A:A),">="&row(sheet2!A:A))=1),2,0),),1,"Issued"),0,"In-Stock"),)})
To handle items in sheet1 that are not in sheet2, you can add a value in the iferror function (the first "In-Stock" below):
=arrayformula({if(A2:A<>"",substitute(substitute(iferror(vlookup(A2:A,filter(sheet2!A:B,countifs(sheet2!A:A,sheet2!A:A,row(sheet2!A:A),">="&row(sheet2!A:A))=1),2,0),"In-Stock"),1,"Issued"),0,"In-Stock"),)})
This is responsible for getting the dataset from sheet2:
filter(sheet2!A:B,countifs(sheet2!A:A,sheet2!A:A,row(sheet2!A:A),">="&row(sheet2!A:A))=1)
This part gets the instance number of each duplicate value in sheet2!A:A:
countifs(sheet2!A:A,sheet2!A:A,row(sheet2!A:A),">="&row(sheet2!A:A))
Where there are duplicate values, ">=" gets the one furthest down the sheet. Changing it to "<=" will get the first instance at the top of the sheet.
Within filter, countifs(sheet2!A:A,sheet2!A:A,row(sheet2!A:A),">="&row(sheet2!A:A))=1) filters the column to show just 1 instance of each value in sheet2!A:A.
Looking at your example sheet, you have these values in row 6, 7, 8, so the first instance (ascending or descending) will be 0:
1230E 0
1230E 1
1230E 0
If you're looking for a different logic, like 1 trumps 0, then you'll need to apply a sort on the data before performing the vlookup. Something like:
=arrayformula({if(A2:A<>"",substitute(substitute(iferror(vlookup(A2:A,unique(sort(sheet2!A2:B,1,1,2,0)),2,0),"In-Stock"),1,"Issued"),0,"In-Stock"),)})

Select the last two names in google sheet

In my data sheet1, I want to use the 'Name in use' column (B) with the last two names with ARRAYFORMULA. 
In my data sheet2, I want column (B) to be repeated with the same code next to the column A get filled 
Please find the sample date sheet below  https://docs.google.com/spreadsheets/d/1_AWRjexJNAcgNGsmrBKU_8JYL03UbAGeiyy4oI8B9fU/edit?usp=sharing 
 Regards,
Nimal PereraSri Lanka
Sheet 1
Your formula seems fine, just the ArrayFormula() needs tweaking. As noted in the docs, ArrayFormula() takes in a range, rather than a single cell.
You would have to do something like this:
=ARRAYFORMULA(IFERROR(UPPER(TRIM(RIGHT(SUBSTITUTE(A2:A5," ",REPT(" ",60)),120)))))
Essentially you type in the range you'd like it to apply on. So at any moment, instead of selecting a single cell for that row, you select the range. If you'd want to apply it to the entire column, use A2:A. You even did it right on sheet2
Sheet 2
Your names seem to be importing correctly once Sheet1 is done right. To have the same code everywhere, use something like this:
=ARRAYFORMULA(IF(LEN(A2:A),"SSD",""))

Trouble with a single cell formula being converted to a full column formula

I have a Google Sheet that has a Google Form populating the results of many games that a friend and I play. I have created a new column and added a formula to the top cell in that column and just copied it down the column:
=JOIN(" / ",(FILTER(MyDecks!B$2:B,MyDecks!A$2:A=B5)),(FILTER(HisDecks!B$2:B,HisDecks!A$2:A=C5)))
MyDecks column A is a list of deck names.
MyDecks column B is an attribute of each deck, which is the desired return value.
B5 and C5 are both within columns of the Sheet tab where the formula exists.
The output when using the formula above is something like "M / P", for example.
This formula however, currently has to be copied and pasted, or just extended down to the new cells any time I add another entry with the Google Form.
I would like this formula to be altered so that it will function the same as it does currently, but have it reside within the column head itself so that new entries will just accept and render the formula automatically for the new entries that I create.
I have tried:
=ArrayFormula(IF(ROW(D:D)=4,"Matchup",IF(ISBLANK(C:C),"",JOIN(" / ",(FILTER(MyDecks!B$2:B,MyDecks!A$2:A=B$5:B)),(FILTER(HisDecks!B$2:B,HisDecks!A$2:A=C$5:C))))))
and many other iterations of the same idea, to no avail. I am a novice and am hoping that there is an easy solution to my issue.
use:
={"Matchup"; ARRAYFORMULA(IFNA(
VLOOKUP(B5:B, JoeDecks!A2:B, 2, 0)&" / "&
VLOOKUP(C5:C, BryanDecks!A2:B, 2, 0)))}

Query and ImportRange with Dynamic Values

I have 2 sheets which are connected.
Sheet-1: Has ID column and Status column (Status field is manually updated by the team)
Sheet-2: Has ID column and Status column (+ many other fields)
Requirement: Status column in Sheet 2 to be updated from Sheet-1 if ID column in sheet-2 = ID column in Sheet-1
I wrote a Query and ImportRange, but I could find Query working only when I compare it against a static value (for e.g. Yes). What I want is it to check against the value in ID column from both the sheets and import only for rows that match.
=QUERY(IMPORTRANGE("1ZkPaYb1IIIkcbVerdmZ-Ru1vxFu1YMWj74QNQj2jles", "Ops Action Sheet!B2:B10000"),"select Col2 where Col1 = 'Yes'")
This doesn't directly answer your question about using QUERY, but I believe that that function might not be the best tool for what you're trying to do.
I write below a solution using the alternative function VLOOKUP.
I am assuming here that by "Sheet-1" and "Sheet-2", you actually mean entirely different spreadsheets, judging by your use of IMPORTRANGE.
If you don't mind having a copy of Sheet-1's contents living within Sheet-2, here is what you can do:
On a new sheet (tab) in Sheet-2, copy this function (fill in sheet_1_url):
=IMPORTRANGE("sheet_1_url", "Ops Action Sheet!$A:$B")
You should see a copy of the data from Sheet-1 in that tab. You can hide this tab or protect it if you wish.
On your main data tab within Sheet-2, copy this formula in your Status column (assuming that your ID is in A2:
=IFERROR(VLOOKUP($A2,range_from_step_1,2,),)
Copy that formula down as much as you need.
However, if you don't want to have a copy of Sheet-1's data in Sheet-2 for whatever reason, you can simply skip steps 1-2 above, going straight to step 3, with the following formula in Sheet-2:
=IFERROR(VLOOKUP($A2,IMPORTRANGE("sheet_1_url", "Ops Action Sheet!$A:$B"),2,),)
Not that I recommend it, since you'd technically be importing your data virtually within the formula N number of times, which will be a huge performance hit.
You can see the references for the formulas used above here:
IMPORTRANGE
VLOOKUP
IFERROR
edit to reflect and paste in spreadsheet 2:
=ARRAYFORMULA(IFERROR(VLOOKUP(A2:A, IMPORTRANGE("ID", "Sheet!A:C"), {2, 3}, 0)))
A2:A - column of IDs in spreadsheet 2
Sheet!A:C - column A of this range hosts IDs
{2, 3} - brings column B and C from spreadsheet 1 into spreadsheet 2

Sort the value of a column with a relative position (using an other column data order)

I've created a form to collect data from user A in a sheet and reformat it for user B in the other sheet.
I have to sort the data for user B. I'm using vlookup to sort the column of values from the form to a new sheet (sort based on the order of the 'value description column'). It's working.
My problem is that when a new column is added to the first sheet (the form) the column range is modified and the index parameter in vlookup is not good anymore. So I lost everything on my second sheet.
How can I do to have a solid link with the column in the first sheet even if it's position change?
you can make use of INDIRECT with COUNTA and SUBSTITUTE. something like:
=INDIRECT("Sheet1!A1:"&SUBSTITUTE(ADDRESS(1, COUNTA(Sheet1!1:1), 4), 1, "")
this will count non-empty cells in row 1 of Sheet1 and converts that number to later which is used in constructing the range put together by indirect formula and all of it can be placed in vlookup as same as you would place any ther regular range.

Resources