Inverse LOOKUP in google sheets to return column name - google-sheets

Good day,
I am currently sorting a storage unit, where various parts from samples are stored in multiple locations. The idea is to sort it. So I am creating a spreadsheet for each part. The columns will be the location and the rows are a list of the sample numbers of which the parts can be found in this location.
input:
A spreadsheet like this will exist for every part.
The idea is to have a final table, sorted by sample number, which has the parts in the columns. I want the cells to return where this part of this sample is stored:
desired output:
I tried various LOOKUP formulas but they do not return the column name.
Because this has to be accessible by multiple people, it has to be in google sheets.
This is an example file: https://docs.google.com/spreadsheets/d/1pUmTs0mLoZAdPc83pLXC75MCUF2P1SHDtEfYPEMohr4/edit?usp=sharing
I am super thankful for any help!

With the help of this website:
https://infoinspired.com/google-docs/spreadsheet/search-across-columns-and-return-the-header/
I found a solution. The idea is to use match functions for each column. For the example posted the code looks like this:
=ifs(isna(match(A2,'Part 1'!$A$1:$A$7,0))=FALSE,'Part 1'!$A$1,isna(match(A2,'Part 1'!$B$1:$B$7,0))=FALSE,'Part 1'!$B$1,isna(match(A2,'Part 1'!$C$1:$C$7,0))=FALSE,'Part 1'!$C$1,isna(match(A2,'Part 1'!$D$1:$D$7,0))=FALSE,'Part 1'!$D$1)
I know it is not pretty, but it works, as the number of columns is limited. The website also suggests a dynamic solution with a query function, but that only works when the cell left of the cell of interest has entries.
Thanks to everyone :-)

Related

Creating headers (and footers) in the middle of returned query data with Google Sheets

I have a table of data that I want to turn from raw data into something a little 'prettier' and organized to look at.
The data consists of payments made (3 columns: Name, payment amount, and date of payment).
I'd like to present the data so that for each group of dates that are the same there is a header above those rows with the date itself so the user can see these rows of dates are for say 1/14/2023.
Then the next set of rows for say 1/15/2023 would have the header 1/15/2023.
Please see the attached image.screenshot
In columns A - C is the raw data and I don't know how many and which dates there will be a priori. In columns E-G is the desired output.
You can see I'd also like if possible a footer that sums the totals for that day.
Any ideas on how to achieve this? The ideal solution would be such that you could paste raw data into columns A-C and then the data shows up in columns E-G formatted. I'm hoping there's a design pattern for this type of thing before I cobble together a solution.
I've implemented something through Apps Script, but am more interested in learning if there's a way through the formulas provided in Sheets.
I can see this possibly being done with temp/work tables, but am wondering if this is a common problem/solution and would love to get pointed in the right direction. I'm a programmer and have been using sheets for about a year and can write queries and filters and do lots of things but want to learn the right way and not always just do something the first way that pops into my head that works.
try this formula along with a bit of conditional formatting to get the expected output.
Headsup: Set Columns E, F to DATE Type formatting
=LAMBDA(czx,MAP(INDEX(czx,,1),INDEX(czx,,2),INDEX(czx,,3),LAMBDA(ax,bx,cx,{ax,IF(ISNUMBER(ax),{"",""},IF(ax="TOTALS",{"",cx},IF(LEN(ax),{bx,cx})))})))(SORT(LAMBDA(ax,FILTER(ax,INDEX(ax,,1)<>""))({BYROW(UNIQUE(B:B),LAMBDA(bx,IF(bx="",,{bx,bx,0})));A:C;BYROW(UNIQUE(B:B),LAMBDA(bx,IF(bx="",,{"TOTALS",bx,SUMIF(B:B,bx,C:C)})))}),2,1))

How do I import multiple rows into a different tab in Google Sheets, based on whether they contain a keyword?

I have a database of blogs, all based around different business units (including information like headline, topic, progress, spokesperson, etc).
I'd like to create separate tabs into which I can automatically pull the rows for each business unit (i.e. containing the keyword for "Banking", or "Energy & Utilities", or "Retail" in a certain column).
Unfortunately, despite looking at some tutorials and examples, I haven't been able to find any VLOOKUP, IMPORTRANGE, or INDEX/MATCH (etc.) functions that can help.
Example:
I've created an example spreadsheet here: https://docs.google.com/spreadsheets/d/19lHTxLaAgtHz5wg0sLLVw1YSpEXvQycL2PUd6Grs4X0/edit?usp=sharing
I'd like to be able to search column C for every row which contains the keyword "Banking" and automatically import all of these rows into a separate tab, named 'Banking'. That formula could then be repurposed for different tabs for each Business Unit.
Is there a formula or solution that would let me do this?
Thank you!
I attempted VLOOKUP, XLOOKUP, INDEX/MATCH, QUERY(IMPORTRANGE) in a separate sheet, and other related functions, but was unable to repurpose these functions to work for my database. Most efforts resulted in error codes or an inability to parse (although I'm more than willing to admit I probably made a mistake).
In A1 of your Banking sheet use:
=FILTER('Master sheet'!A:E,'Master sheet'!C:C="Banking")
You can try either of these in your Banking tab:
=QUERY('Master sheet'!A:E,"WHERE C='Banking'",1)
OR
={'Master sheet'!A1:E1;FILTER('Master sheet'!A:E,'Master sheet'!C:C="Banking")}
OR
=LAMBDA(z,{chooserows(z,1);filter(z,choosecols(z,3)="Banking")})('Master sheet'!A:E)
=QUERY(IMPORTRANGE("19lHTxLaAgtHz5wg0sLLVw1YSpEXvQycL2PUd6Grs4X0","Master Sheet!A:E")," Select * where Col3 Contains 'Banking' ")
or
=QUERY(IMPORTRANGE("19lHTxLaAgtHz5wg0sLLVw1YSpEXvQycL2PUd6Grs4X0","Master Sheet!A:E")," Select * where Col3='Banking' ")

I can't figure out how to transpose unique values based on specific critera in Google Sheets

I'm trying to create an inventory system for my business. For example, our SKU codes start with "LMS" "RSP" and "CON" for specific locations where we're working.
I'm trying to take all unique "LMS" codes, and copy them to a single sheet from our raw scan data. I've tried variations on REGEXMATCH, and UNIQUE, and TRANSPOSE, IF statements, and , but I'm totally lost. This is not my normal preview.
For example, I've been trying things like:
=FILTER(RAW!B2:B,RAW!B2:B=UNIQUE(RAW!B2:B),REGEXMATCH(RAW!B2:B,"LMS"))
and
=IF(REGEXMATCH(RAW!B2:B,"LMS"),(TRANSPOSE(RAW!B2:B)),"error")
The second example returns all values in RAW!B, while the first one does nothing. Any help would be appreciated.
Try below formula-
=UNIQUE(FILTER(Raw!B2:B,REGEXMATCH(Raw!B2:B,"LMS")))
Or QUERY() function with wild card match-
=UNIQUE(QUERY(Raw!B2:B,"select B where B like 'LMS%'"))

IMPORTRANGE with Blacklist on Google SHeets

I'm quite novice so I apologize if this is obvious. I'm trying to have an import range show names and another value from another google sheet, but exclude those from a blacklist. I have pasted the formula I'm currently working with below. Any ideas?
=QUERY(IMPORTRANGE("XXXXX", "XXXX!$A:$B"), " skipping != 'Blacklist'!$A:$A")
The import range it pulls from is a Filter already, I've pasted that below. Could it be worked there?
=IFERROR(FILTER('XXXXX'!$A:$B, 'XXXXXX'!$H:$H = "ABCD")," ")
Thanks in advance!
FILTER is my preferred way of removing from a list.
Here is the formula
=FILTER(A2:A6,NOT(COUNTIF(B2:B3,A2:A6)))
You can think of it like
=FILTER( list ,NOT(COUNTIF( needle , haystack)))
Usually you use this to whitelist a document (hence why I dedicated this formula to memory in a needle-haystack fashion.) But by throwing in the NOT in the criteria of the filter, it works great for blacklisting too!
As to why it works, I'm not sure, my best guess is when google sheets is running through the COUNTIF for any given cell if it meets the criteria it will return a '1' which is truthy and it includes it in the results. This also allows us to compare un-even amounts of data. ie. B2:B3 rather than B2:B6

Check cell for multiple strings and return specific values

I'm trying to create a Google Sheet formula that searches for a word in a longer string and returns a specific value based on the string being searched.
I can achieve this in Excel but I need this to work in Google Sheets.
Below is an example of what I'm trying to achieve:
The "Sort" column is retrieving the value based on checking if the word in column "C" exists in column "A".
I've tried using wildcard search but this isn't working for me in Google Sheets, and other examples I've seen online don't seem to allow me to return multiple values.
Any help would be much appreciated.
This formula may fit you:
=IFERROR(REGEXEXTRACT(A1,JOIN("|",FILTER(C:C,C:C<>""))),"none")
Here're some useful links:
REGEXEXTRACT
JOIN
FILTER

Resources