Google Sheets vlookup based on multiple criteria with wildcards - google-sheets-formula

I'm trying to extend a gs vlookup formula with a 2nd criteria.
This formula works fine with 1 criteria in column A.
=ArrayFormula(IFNA(VLOOKUP(""&A2:A&"",sheet2!C:D,2,FALSE), ""))
But I would like to extend the formula with a 2nd (OR) criteria .
That sould somehow look like this:
=ArrayFormula(IFNA(VLOOKUP(""&A2:A&"" OR ""&B2:B&"",sheet2!C:D,2,FALSE), ""))
(The fomula shoud check if one of the 2 criterias (in column A or B) matches with column C on sheet2 and return the value from D on sheet2)
Is this even possible with a fomula?

This formula seems to do what you're looking for, placed in C2:
=ArrayFormula(
IFNA( VLOOKUP(A2:A,Sheet2!C:D,2,0),
IFNA(VLOOKUP(B2:B,Sheet2!C:D,2,0),"no match")))
I think there are several other ways of doing this, but I went with what you'd started with.
I haven't added error checking yet, for blank rows, etc., to keep it straightforward.

Related

How use filter formula in Google Sheet with data contains #N/A

For my example, I have 2 columns A,B in Google Sheet
Column A with list of Stocks symbols like AAPL, IBM, etc....
Column B with simple formula of GOOGLEFINANCE(A2,"price")
Sometimes GOOGLEFINANCE returns error and the cells display #N/A. But this is not my issue...
I would like using filter in column B which show all symbols with prices greater than 100 or #N/A
I prefer not using extra column to achieve that
I'm struggling with it and still didn't find the way to get my result
Just note, my issue isn't GOOGLEFINANCE, It's like example to get the #N/A value
My tought was using filter with formula like: =OR(ISNA(B:B), B:B>100)
But it seems it's ignore the #N/A and doesn't show it
Link for example
In my question I tried the formula "=OR(ISNA(B:B), B:B>100)"
But I must know that if Google Sheets "see" cells with N/A on this column - The result is automatically N/A, even if I put the ISNA in the first condition
So to solve it I used a formula like this:
=IF(ISERROR(B:B), TRUE, B:B>100)
I updated the sheet if someone wants to check it

ArrayFormula column disappears when sorting in a filter view in Google Sheets

I'd like to use ArrayFormula to populate a column in spreadsheet, but when I Sort A->Z in a filter view, the ArrayFormula column vanishes. In some cases, the column includes a #REF! error about the range, and in some cases the column is just blank after the Sort. The following is a simplified version of what I'm trying to do (in my actual application, I'm doing a Vlookup to another sheet):
https://docs.google.com/spreadsheets/d/1XbqqedOjuSKuE-ZLIHNw59-r01EsNMpx7YVqOoxSOR4/edit?usp=sharing
The column 3 header uses an ArrayFormula to copy from column 1. If you go to the Filter 1 filter view, you'll note that column 3 is blank except for an error. This happens after I try to Sort Z->A on column 2. In my more complicated use-case, involving a Vlookup, after a Sort the column disappears entirely (leaving no #REF! error). Before sorting in both cases, everything is fine.
How do I make ArrayFormula values persist in filter views after sorting?
Thanks for your help!
I'm guessing that, because your references are normal (relative, not anchored/absolute), the range A2:A10 after sorting down turns into something absurd, like A7:A4, depending on actual sorted values.
Also, if you hover with your mouse on the #REF error, what does it tell you?
Anyway, try using absolute references in your formula:
=arrayformula({"Column 3"; A$2:A$10})
Edit
Fascinating. It's the first time I see this type of error. Taking it at face value, it seems that it's a limitation of Google Spreadsheets - you cannot use ARRAYFORMULAS spanning multiple rows inside sorted filter views, because, like I sort of guessed, it messes up the ARRAYFORMULA's range (as indicated by the fact that the formula is now in C4 instead of C1).
But that gives you also the solution: do not include the cell with the arrayformula in the filter view. Instead of making your filter view's target range A1:C20, make it A1:B20. Then the arrayformula in C1 will be untouched by the filter and will indeed continue to work.
I have found a solution for my usecase, in your case, it could be:
=arrayformula(if(row(C:C)=1;"Column 3";A:A))
But you'll need to consider the whole columns in your formulas.
Example
Have you tried A2:A?
If you don't put an ending row, means the end of the column.
It worked for me.
Cheers

How to filter entries that are not duplicates of entries from others columns in Google Sheets?

I have a column called "Masterlist" which contains values from Lists 1, 2 and 3. It also contains values which are present only in Masterlist.
How can I filter them, like shown at the attached image in Google Sheets?
EDIT: The lists will have more than one entries.
Solution 1
In E2, type in
=filter(A2:A,arrayformula(iserror(match(A2:A,B2:D2,0))))
Check the documentation of filter or match for how to use them. With match, be sure to include the third argument. That is an easy one to forget. arrayformula iterates a formula over a range. The output can be a range, in which case it will print over any un-written cells. When arrayformula interacts with match, it only iterates over the first argument, which is why this solution works.
EDIT: If you have a two-dimensional range to match to, you need to collapse them into a one-dimensional range using the concatenation operators such as
=filter(A2:A,arrayformula(iserror(match(A2:A,{B2:B4;C2:C4;D2:C4},0))))
You can experiment with endings without row indices and let Google Sheets select an ending index for you.
Solution 2
Use the native Filter View feature. Good for the scenarios where you don't need to separately print a list of the unique values in "masterlist".
Go to Data -> Create Filter View
Use the relevant help pages to navigate yourself. I can see a few ways to implement what you desire, including
filter by value on the same column (selecting the actual values manually);
filter by value on a "helper column" where you include a formula in the cells to check whether the content in "masterlist" belongs to the list you want to check against. You can use the match and iserror combo here;
custom formula using a similar formula as above.
If your column A, ie. the "masterlist", is something a user would add to, then Data Validation can be used to good effect in conjunction with Filter View.

How to sort only those rows which have no blank cell?

I have a Google Spreadsheet with two separate sheets. The first one is just a big list of names and data, and the second is supposed to be a sorted listing of all the data on the first sheet (sorted by, say, last name). Here is the current way I am defining the second sheet:
=sort(sheet1!A2:L100, sheet1!D2:D100, TRUE)
Which works fine for the most part, except for one issue: in sheet1, some of the cells in 4th column (column D) are blank. How can I change the formula so that the sorting ignores such rows which has a blank cell in column D?
The formulas i tried but got undesirable results :
=arrayformula(if(istext(sheet1!D2:D100), sort(sheet1!A2:L100, sheet1!D2:D100, true), ""))
It sorted as desired but with one issue - blank cells were not pushed at the end but scattered in between the rows.
=arrayformula(sort(filter(sheet1!A2:L100, istext(sheet1!D2:D100)),sheet1!D2:D100, true))
Though the filter part does its job perfectly but when coupled with sort, it is giving an error : Mismatched range lengths.
To filter out the rows with blank cells in column D, you could do something like #2, but as the error message suggested, the second argument would need to be filtered as well to ensure the ranges are the same length. Fortunately there is an easier way, and that is to use column indices rather than ranges:
=SORT(FILTER(sheet1!A2:L100;ISTEXT(sheet1!D2:D100));4;TRUE)
Alternatively you can use the QUERY function for this sort of thing:
=QUERY(sheet1!A2:L100;"select * where D != '' order by D";0)
For anyone looking this, the accepted answer works great if filtering out blank cells that are truly blank, but if the cells contain formulas that evaluate to blank (""), ISTEXT will evaluate to TRUE and blanks will not be filtered out. I modified the accepted answer slightly to work in my situation, in which I had cells containing formulas (that evaluated to "") that I wanted to filter out:
=SORT(FILTER(sheet1!A2:L100,sheet1!D2:D100 <> ""),4,TRUE)

Google Spreadsheet filter

I'm trying to filter a list of employee by department in google spreadsheet
=filter(A:C,!B2:B6=D2)
my sample data is
Name Department age
asd dep1 12
fds dep2 2
plo dep3 3
sdfsdf dep1 56
shg dep2 98
now I already got the filter part working.. my question is after filtering. how can I tell GSpreadsheet to only display specific column values... like use department as filter condition but only return name and age?
eventually I also want to move my result to a different sheet.
My first choice of approach for this issue was to use google macro like thingy and just hide the rows and comlumns not needed if you have suggestions for this please don't hesitate to provide.
The easiest way to filter is the [Data-Filter], otherwise [View-List] is also able to filter. Using a formula you will be displaying the results in a different column, usually on a different page.
My suggestion to omit column B would be to make two separate column filters like this:
=filter(A:A,B:B=D2)
=filter(C:C,B:B=D2)
The exclamation is only necessary if you are on another sheet, you may also be trying to do something like this: filter(A2:A,B2:B="dep1") the real power of the formula is where you want to manipulate the value before your comparison like this: filter(A:A,right(B:B,1)="1") otherwise I'm not sure what you are referring to, other than Google Apps Scripts I am not aware of any functionality very similar to VBA.
If this did not answer your question can you be a little bit more specific?
I would use the QUERY function here:
=QUERY(A:C, "select A,C where (B = 'dep1')")
This will return with two columns (Name and Age - that is "A" and "C" respectively). The filter condition is provided in the WHERE clause.
For moving the result to another sheet, I would do it another way around: Create another sheet, and then write:
=QUERY(employees!A:C, "select A,C where (B = 'dep1')")
Assuming that your original worksheet's name is "employees".
I hope it helped.

Resources