So I'm creating an export worksheet on my spreadsheet as I would like a consistent way to VLOOKUP using an IMPORTRANGE from this sheet. I have 3 datasets and I would like to add a prefix column to the export worksheet so I'm able VLOOKUP which dataset the data comes from. My initial though was to use this formula ={"Dataset 1", 'Dataset 1'!$A$2:$C6; "Dataset 2", 'Dataset 2'!$A$2:$C11; "Dataset 3", 'Dataset 3'!$A$2:$C16} however I'm unable to use this because the strings I am adding aren't rows of data, I understand why I can't use this formula however I'm unsure how to accomplish what I'm trying to do here.
Here is an example spreadsheet with my desired outcome. Thanks for any help!
Try:
=arrayformula(query(
{
iferror(row('Dataset 1'!A:A)/0,"Dataset 1"),'Dataset 1'!A:C;
iferror(row('Dataset 2'!A2:A)/0,"Dataset 2"),'Dataset 2'!A2:C;
iferror(row('Dataset 3'!A2:A)/0,"Dataset 3"),'Dataset 3'!A2:C
},
"where Col2 is not null label Col1 'Dataset:'",1))
Alternatively, use FILTER:
=ARRAYFORMULA({
"Dataset:", "Name:", "ID:", "Apples:";
IFERROR(FILTER('Dataset 1'!A2:A, 'Dataset 1'!A2:A <> "") / 0, "Dataset 1"), FILTER('Dataset 1'!A2:C, 'Dataset 1'!A2:A <> "");
IFERROR(FILTER('Dataset 2'!A2:A, 'Dataset 2'!A2:A <> "") / 0, "Dataset 2"), FILTER('Dataset 2'!A2:C, 'Dataset 2'!A2:A <> "");
IFERROR(FILTER('Dataset 3'!A2:A, 'Dataset 3'!A2:A <> "") / 0, "Dataset 3"), FILTER('Dataset 3'!A2:C, 'Dataset 3'!A2:A <> "")
})
If you want the blank rows to appear, use:
=ARRAYFORMULA({
"Dataset:", "Name:", "ID:", "Apples:";
IFERROR(row('Dataset 1'!A2:A) / 0, "Dataset 1"), 'Dataset 1'!A2:C;
IFERROR(row('Dataset 2'!A2:A) / 0, "Dataset 2"), 'Dataset 2'!A2:C;
IFERROR(row('Dataset 3'!A2:A) / 0, "Dataset 3"), 'Dataset 3'!A2:C
})
Related
I would like this multiple-criteria query not to show empty columns.
=QUERY({H3:M11}, "select * WHERE
"&TEXTJOIN(" and ", 1,
IF(C3<>"", "Col2 = "&C3&"", ),
IF(B3<>"", "Col3 = '"&B3&"'", )), 1)
Besides, I would also like to know if it's possible to filter it outside a query formula. Currently, I have this formula made by #player0 which is excluding columns with values greater than 0, but I didn't manage to make it work for text.
=FILTER(FILTER(H3:M11, LEN(TRIM(QUERY(IFERROR(1/(1/H4:M11)),,9^9)))>0), {9;
LEN(TRIM(FLATTEN(QUERY(TRANSPOSE(IFERROR(1/(1/H4:M11))),,9^9))))}>0)
Link to the question where this filter formula was found.
Here's the sheet.
Thanks a lot.
try:
=ARRAYFORMULA(QUERY({H3:K11,
FILTER(L3:M11, TRIM(QUERY(L4:M11,,9^9))<>"")},
"where "&TEXTJOIN(" and ", 1,
IF(C3<>"", "Col2 = "&C3&"", ),
IF(B3<>"", "Col3 = '"&B3&"'", )), 1))
I saw this question but was not able to get it to work for me. Since it is already answered and from an year ago I felt it best to post a new question.
I have a sample sheet at: https://docs.google.com/spreadsheets/d/1EqNfTWcNFgkv2gdovnH7JpqU9V2HG5Vkoup8bhNqI7k/edit#gid=0
In F1 I want an array formula that will join the values of B1:E1 if B2:E = "yes".
Column G has the expected output.
This is what I came up with but it's giving error:
={
"output";
ARRAYFORMULA(
IF(
A2:A = "",
,
IF(
B2:E = "yes",
TEXTJOIN(", ", TRUE, B1:E1),
)
)
)
}
Try this out
=index(substitute(trim(transpose(query(transpose(if(B2:E<>"yes",,B1:E1)),,9^9)))," ",", "))
If the header contain spaces, use:
=index(substitute(substitute(trim(transpose(query(transpose(if(B2:E<>"yes",,substitute(B1:E1," ","❄️"))),,9^9)))," ",", "),"❄️"," "))
use:
=INDEX(REGEXREPLACE(TRIM(FLATTEN(QUERY(TRANSPOSE(
IF(B2:E="yes", B1:E1&",", )),,9^9))), ",$", ))
I have a Google Sheet that imports column "L" from another file based on the row number
=ArrayFormula(
IF(LEN(K:K),
if( ROW(L:L) = 1,
"Date",
IMPORTRANGE("https://docs.google.com/spreadsheets/d/123456123456lkjjj","Sheet1!D" & M1:M)
),""
)
)
other file (Sheet1)
The problem always return the first result
Try this:
=ARRAYFORMULA(
IFS(
ROW(L:L) = 1,
"Date",
K:K = "",,
True,
IFNA(VLOOKUP(
M:M,
{
SEQUENCE(ROWS(IMPORTRANGE("https://docs.google.com/spreadsheets/d/123456123456lkjjj", "Sheet1!D:D"))),
IMPORTRANGE("https://docs.google.com/spreadsheets/d/123456123456lkjjj", "Sheet1!D:D")
},
2,
))
)
)
IMPORTRANGE works once inside ARRAYFORMULA, so it is not possible to call it in a loop. But you can get everything with it and then loop through it.
I'm using a formula in Google Sheets that combines vlookup and importrange to look to the left in a separate spreadsheet. Here's the formula...
={
"Staff Name";
arrayformula(
iferror(
VLOOKUP(
A2:A,
{
IMPORTRANGE("1Ri5k_WNei8X9XJVWxrblSuEKS3680YcH3LobflvmzuALcsY","Directory!D2:D"),
IMPORTRANGE("1Ri5k_WNei8X9XJVWxrblSuEKS3680YcH3LobflvmzuALcsY","Directory!C2:C")
},
2,
0
),
""
)
)
}
But, let's say I need to look 6 columns to the left, instead of just 2. Do I need to do an importrange for every single column like the above formula? Or is there an easier way?
In other words, will my formula need to change to look like this below?
={
"Staff Name";
arrayformula(
iferror(
VLOOKUP(
A2:A,
{
IMPORTRANGE("1Ri5k_WNei8X9XJVWxrblSuEKS3680YcH3LobflvmzuALcsY","Directory!H2:H"),
IMPORTRANGE("1Ri5k_WNei8X9XJVWxrblSuEKS3680YcH3LobflvmzuALcsY","Directory!G2:G"),
IMPORTRANGE("1Ri5k_WNei8X9XJVWxrblSuEKS3680YcH3LobflvmzuALcsY","Directory!F2:F"),
IMPORTRANGE("1Ri5k_WNei8X9XJVWxrblSuEKS3680YcH3LobflvmzuALcsY","Directory!E2:E"),
IMPORTRANGE("1Ri5k_WNei8X9XJVWxrblSuEKS3680YcH3LobflvmzuALcsY","Directory!D2:D"),
IMPORTRANGE("1Ri5k_WNei8X9XJVWxrblSuEKS3680YcH3LobflvmzuALcsY","Directory!C2:C")
},
6,
0
),
""
)
)
}
Thanks for your help!
Need to know how to put Max Offset function into array formula.
=ArrayFormula(MAX(OFFSET(M42:M46,0,0,5,1)))
This is what I am wanting to change it from.
=MAX(OFFSET(M42,0,0,5,1))
Here is the example in sheets.
https://docs.google.com/spreadsheets/d/180M_qJCE0Bhz5jRX-tAyBc7DIp7HQpCNVGGlrkuguso/edit?usp=sharing
why not:
=ARRAYFORMULA(QUERY(TRANSPOSE(QUERY(TRANSPOSE(ARRAY_CONSTRAIN(SPLIT(TRANSPOSE(QUERY(
TRANSPOSE(ARRAY_CONSTRAIN(IF(IFERROR(SPLIT({"";REPT("♦"&ROW(INDIRECT("A1:A"&COUNTA(M42:M))),
ROW(INDIRECT("A1:A"&COUNTA(M42:M))))}, "♦"))<>"", , TRANSPOSE(SPLIT(REPT(
INDIRECT("M42:M"&COUNTA(M42:M)+41)&" ", COUNTA(M42:M)-5+1), " "))),
COUNTA(M42:M)-5+1, COUNTA(M42:M))), , COUNTA(M42:M))), " "), COUNTA(M42:M)-5+1, 5)),
"select "&TEXTJOIN(",", 1, IF(LEN(TRANSPOSE(SPLIT(REPT("♥♠", COUNTA(M42:M)-5+1), "♥"))),
"max(Col"&ROW(A1:A)&")", ))&"")),
"select Col2"))