I've been toying with a few ways to do what I want to do, so I'll start with an example of my goal:
So, in the linked sheet, I have a table with colors and animals, and then a list of entries, each with a color and animal together. My goal is this: Take the string from one of the cells in column E, i.e. E2: Red Cat, and use that information to find the associated cell, and return either the cell reference B2, or the data contained where they intersect, in this case TRUE.
I opted for the cell content rather than the cell addresses. Please try:
=OFFSET($A$1,MATCH(INDEX(split(E2," "),1),A:A,0)-1,MATCH(INDEX(split(E2," "),2),$1:$1,0)-1)
If you alter a little bit code given by #pnuts then you will get cell reference:
=ADDRESS(MATCH(INDEX(SPLIT(E2," "),1),A:A,0),MATCH(INDEX(SPLIT(E2," "),1,2),$1:1,0),4)
The last paramether could be 1-4 and the results:
$B$2
B$2
$B2
B2
also you are able to add sheet name to reference, then it would be:
=ADDRESS(MATCH(INDEX(SPLIT(E2," "),1),A:A,0),MATCH(INDEX(SPLIT(E2," "),1,2),$1:1,0),4,,"SheetName")
and the result -> SheetName!B2
Maybe a good way to automate your task is to use array formulas:
The formula is F1 to split values:
=FILTER(SPLIT(E2:E," "),E2:E<>"")
The formula in H2 to get addresses:
=FILTER(ADDRESS(MATCH(F2:F,A:A,),MATCH(G2:G,1:1,),4),E2:E<>"")
or put this in H2 to get values:
=FILTER(VLOOKUP(F2:F,A:C,MATCH(G2:G,1:1,),0),E2:E<>"")
Related
I am trying to generate an arrayformula for the whole column but it does not work, when I use the same formula cell by cell, it generates correct value. Here is the formula for F1 cell:
=if(Iferror(vlookup($D1, INDIRECT("$"&"A"&MATCH(E1,$B:$B,0)+1&":$B"),2,false),"")=E1,"",Iferror(vlookup($D1, INDIRECT("$"&"A"&MATCH(E1,$B:$B,0)+1&":$B"),2,false),""))
I am trying to convert it into ArrayFormula like this and put it in F1:
=ARRAYFORMULA(if(Iferror(vlookup($D:$D, INDIRECT("$"&"A"&MATCH($E:$E,$B:$B,0)+1&":$B"),2,false),"")=$E:$E,"",Iferror(vlookup($D:$D, INDIRECT("$"&"A"&MATCH($E:$E,$B:$B,0)+1&":$B"),2,false),"")))
But this does not work and returns empty column, here is the sheet if you want to test it, you can find formula in column F:
https://docs.google.com/spreadsheets/d/13XLZvvdzK_mqr4Ous50cIEfernw2XrPJWvVgt1hFxtk/edit?usp=sharing
Please share your knowledge how to go about it as I am trying to learn formulas starting from basic level? Thank you.
when working with more than one condition, you can usually use FILTER for it. In this case, I used MAP to refer to both columns D and E, and used FILTER to narrow to the matches in A column, and then to those values that were further than the row of the MATCH of E value. Then, with INDEX I chose the first value of that resulting range.
=MAP(D:D,E:E,LAMBDA(d,e,IFERROR(IF(d="","",INDEX(FILTER(B:B,A:A=d,ROW(B:B)>MATCH(e,B:B,0)),1)))))
Unclear of the full scope but from your expected result scenario(in Column F) you seem to be pulling off second match(if any). well in that case try:
=BYROW(D:D,LAMBDA(dx,IF(dx="",,IFNA(FILTER(ARRAY_CONSTRAIN(FILTER(B:B,A:A=dx),2,1),{0;1})))))
in Google Sheets using formulars I would like to build an array of the columns that fulfills a simple criteria, so for example:
A
B
C
D
E
F
G
h1
h2
h2
h1
h3
h2
h1
Then I would like to have the array {A:A,D:D,G:G} if I search for 'h1'
I suppose what you want is to get the Column letter of the cell if some criteria is met. Like :"what colums have the right answer?" and the return that letter in some way.
So as far as i know sheets does not provide that as a simple function. (But im not very skilled in sheets).
Heres a hacky thing that might work for you:
Somwhere in your sheet (eg bottom row # 100 make cells that hold your letters
So A100 holds "A" or "A:A" B100 holds "B" or "B:B" and so forth.
then you can use filter function.
If the row you want to want to investigate is the first:
code:
=FILTER(A100:Z100;A1:Z1="h2")
that will give you your array.
Cheers Mads
Suppose your raw data is in a sheet named Sheet1.
In a new sheet (e.g., Sheet2), place the following formula in A1:
=IFERROR(FILTER(Sheet1!A:G,Sheet1!A1:G1="h1"))
You could also place this version of the formula in Sheet2 cell B1:
=IFERROR(FILTER(Sheet2!A:G,Sheet2!A1:G1=A1))
... and then enter "h1" (or some other text to match) into cell A1.
ADDENDUM (after further comment from OP):
=IFERROR(FILTER(REGEXREPLACE(ADDRESS(1,COLUMN(Sheet2!A:G),4)&":"&ADDRESS(1,COLUMN(Sheet2!A:G),4),"\d",""),Sheet2!A1:G1="h1"))
heres a pice of code that will give you the column letter for any column.
Maybe you can use this in your code, or you can paste it in a cell and copy drag vertically it to get the column letters, like i sugested in previous post.
=IF(TRUNC((column()-1)/26)<1;CHAR((MOD((column()-1);26))+65);CHAR(TRUNC((column()-1)/26)+65)&CHAR((MOD((column()-1);26))+65))
Good Luck :)
OK, relatively simple, but frustrating for me. I think my issue isn't with the TEXTJOIN, but in defining a non-continuous series of cells for the UNIQUE function.
In cell A1, I am using this formula:
=TEXTJOIN("
",UNIQUE(B1,E1,H1,K1,N1))
NOTE: I am trying to do this for a row, and not the entire column that the data is in.
My thought was that it would join only unique values from that series, separated by a hard return.
However, I get an error.
Image of a Google Sheet error with my formula
So, looking for a way to look at a non-continuous series of cells in a row, pull out only unique values, and TEXTJOIN them together with a hard return (new line).
Your formula should be
=textjoin(" ",true,unique({B1;E1;H1;K1;N1}))
encapsulate the cells by {}
try:
=JOIN(" "; UNIQUE({B1;E1;H1;K1;N1})
or:
=QUERY(UNIQUE({B1;E1;H1;K1;N1}),,9^9)
So I have two rows:
ID
TagDog
TagCat
TagChair
TagArm
Grouped Tags (need help with this)
1
TRUE
TRUE
TagDog,TagArm
Row 1 consists mainly of Tags, while rows 2+ are entries. This data ties ENTRIES to TAGS.
What I'm needing to do is concatenate/join the tag names per entry. For example, look at the last column above.
I suspect we could write a formula that would:
Create an array of non-empty cells in the row. (IE: [2,4])
Return it with the header row A (IE: [A2,A4])
Then join them together by a comma
But I am unsure how to write the formula, or if this is even the best approach.
Here's the formula:
={
"Grouped Tags (need help with this)";
ARRAYFORMULA(
REGEXREPLACE(TRIM(
TRANSPOSE(QUERY(TRANSPOSE(
IF(NOT(B2:E11),, B1:E1)
),, COLUMNS(B1:E1)))
), "\s+", ",")
)
}
The trick used is called vertical query smash. That's the part:
TRANSPOSE(QUERY(TRANSPOSE(...),, Nnumber_of_columns))
You can find a brief description of this one and his friends here.
I wasn't able to create a single formula that would do this for me, so instead, I utilized a formula inside of Sheets' Find/Replace tool, and it worked like a charm!
I did a find/replace, replacing all instances of TRUE with the following formula:
=INDIRECT(SUBSTITUTE(LEFT(ADDRESS(ROW(),COLUMN()),3),"$","")&"$1")
What this formula does is it finds the cell's letter, then gets the first row of the cell using INDIRECT.
Breaking down the formula:
ADDRESS(ROW(),COLUMN()) returns the direct reference: $H$1
LEFT("$H$1",3) returns $H$
SUBSTITUBE("$H$","$","") replaces the dollar signs ($) and returns H
INDIRECT(H&"$1") references the exact cell H$1
Now, I can replace all instances of TRUE with that formula and the magic happens!
Here is a video explanation: https://youtu.be/SXXlv4JHDA8
Hopefully, that helps someone -- however, I would still be interested in seeing what the formula is for this solution.
Tried searching and checking Google documentation but I am still having issues getting the results that I want for this problem.
I'm needing to split several comma-separated lists of items and recombine them so that first items in each list is combined, followed by the second item, etc.
To ask with an illustration, if I have a cell with the following
Paul, John, George, Ringo
and another cell with the following
McCartney, Lennon, Harrison, Starr
How do I use one function to produce this in a cell?
Paul McCartney, John Lennon, George Harrison, Ringo Starr
Here you go, you will need to copy to every row - but assuming your data is in columns A and B it will work across a dynamic number of items:
=ARRAYFORMULA(join(",",split(A1,",")&" "&split(B1,",")))
See image example below, in row one i used the data you showed up top, and in row two i reversed the column data just to show as an example:
If you paste the first word CSV to Sheet1 and the second word CSV to Sheet2 then you could put the following into sheet3
In Cell A1:
=Sheet1!A1&" "&Sheet2!A1
This is saying take the value in sheet1 A1 and then a space " " then the value in sheet2 A1
You could also do this with the concatenate function:
=CONCATENATE(Sheet1!A1," ",Sheet2!A1)
Then just copy the formula to suit.