All, I am attempting to parse a column, transpose its contents and join it to another column. I have seen a few variations of how to accomplish with a mix of ARRAYFORMULA(), TRANSPOSE(), SPLIT() which almost works but most of them filter out blanks. In my case, the column being parsed may have rows with blanks which is perfectly normal. Sample input and desired output below and shared sheet. Thanks in advance.
https://docs.google.com/spreadsheets/d/1OCJU5BGAWMt99cuufWlsua0oNCZCYjrEEFfH-YWbj4Q/edit?usp=sharing
try:
=ARRAYFORMULA(SORT(UNIQUE(IFERROR(SPLIT({IFERROR(FILTER(A2:A, B2:B=""));
TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(TRANSPOSE(IF((
IFERROR(SPLIT(B2:B, ";"))<>""),"♦"&A2:A&"♣"&
IFERROR(SPLIT(B2:B, ";")), )),,99^99)),,99^99), "♦"))}, "♣")))))
or:
=ARRAYFORMULA(ARRAY_CONSTRAIN(SORT(UNIQUE(IFERROR(SPLIT({
IFERROR(FILTER(A2:A&"♣ ♣"&ROW(A2:A), B2:B="", A2:A<>""));
TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(TRANSPOSE(IF((
IFERROR(SPLIT(B2:B, ";"))<>""),"♦"&A2:A&"♣"&
IFERROR(SPLIT(B2:B, ";"))&"♣"&ROW(A2:A), ))
,,99^99)),,99^99), "♦"))}, "♣"))), 3, 1), 99^99, 2))
This might also work:
=ARRAYFORMULA(SUBSTITUTE(QUERY(SPLIT(FLATTEN(A2:A23&"|"&SPLIT(IF(B2:B23="","#",B2:B23),";")),"|",0,0),"where Col2<>''"),"#",""))
Related
Hi I have data on columns A, B, C, D on Google sheet
I added the following formula on H2 which works in importing columns C & D as wished.:
=UNIQUE(filter(C2:D,A2:A<>""))
I tried inserting this formula in J2 but it doesn't handle duplicates:
=ARRAYFORMULA(IF(H2:H=C2:C,B2:B))
My goal is to get the results written manually in G columns on this snip and keep the previous formulas. It should write the name of door twice if necessary separated by a comma or write the different doors in the same cell adjacent to the name.
Please help
This can be achieved with the formula below
=join(", ",filter($A$2:$A, $B$2:$B=D2))
Unfortunately, this formula is not an arrayformula, and I am not completely certain how to turn it into one (if there is a way). Because of that, this formula will need to be dragged down the column you place it in.
Here is an example of it working in the test sheet I made:
I will continue to try to make this usable with an array formula, and will edit this answer if I am able to find a solution.
Hope this helps! Let me know if you have any questions.
use:
=ARRAYFORMULA(REGEXREPLACE(TRIM(SPLIT(FLATTEN(QUERY(
QUERY({A2:A&",", B2:B&"×", ROW(B2:B)},
"select max(Col1) where Col1 <> ',' group by Col3 pivot Col2"),,9^9)), "×")), ",$", ))
Like I ask in title, what is the best way to write formula like this one below. I want sum from all sheets values for Germany (values are in B column)
=SUM(SUMPRODUCT(--(First!A2:A11="Germany"),(First!B2:B11)), SUMPRODUCT(--(Second!A2:A11="Germany"),(Second!B2:B11)), SUMPRODUCT(--(Third!A2:A11="Germany"),(Third!B2:B11)))
What is your opinion?
In Google Sheets you can also use
=QUERY({L1:M9;O3:P7},
"select sum(Col2) where Col1 ='xxx' label sum(Col2) 'Total' ",1)
(Please adjust ranges to your needs)
How the formula works.
We create an array using curly brackets {} stacking the ranges one on top of the other using semi-columns ; even from other sheets like {L1:M9;O3:P7;First!A2:B11;Second!A2:B11}. One can add as many ranges as needed. Even open ranges.
The ,1 in the end of the formula shows that the very first row will be treated as a header row.
Please read more about the QUERY. function
try:
=SUM(FILTER({First!B2:B11; Second!B2:B11},
{First!A2:A11; Second!A2:A11}="Germany"))
One more option:
=SUMPRODUCT(({First!A2:A9;Second!A2:A9}="Germany")*{First!B2:B9;Second!B2:B9})
I am unable to figure out how could we use formula within query results. I did not find any solution yet.
Like:
=query(sheet1!A1:Z,"Select A,B,Vlookup(D,sheet1!A1:A,1,false)");
If your range is A1:Z, the column where you can insert the formula without error must be bigger than Z
Sheet formulas do not expect (nor allow) semicola at the end
If D is a string, it should be nested in double quotes
To combine your formulas, you need to combine the quotes correctly, e.g.:
=query(Sheet1!A1:Z, CONCATENATE("select A,B,",Vlookup("D",Sheet1!A1:A,1,false)))
you can't. you need to do:
=ARRAYFORMULA({sheet1!A:B, IFNA(VLOOKUP(D:D, sheet1!A:A, 1, 0))})
and then you can play with query:
=ARRAYFORMULA(QUERY({sheet1!A:B, IFNA(VLOOKUP(D:D, sheet1!A:A, 1, 0))}, "select Col1,Col2,Col3", 0)
So I have a workbook with 3 sheets. The first contains data from A:Z. The second also contains data from A:Z, but the data is different. The third page is used to query the other by using Filter.
I want to be able to write a single formulate that will Filter data from sheet 1 and display the results, and then starting from the next available row, Filter data from sheet2 and display those results, without any gaps or overwriting.
If the two filters are something like this:
=FILTER(sheet1!A:Z, sheet1!A:A="Bob")
and
=FILTER(sheet2!A:Z, sheet2!A:A="Bob")
So, the only difference between the two filters is the sheet name.
I won't know in advance how many rows of output each filter will produce, so I can't just put the second Filter formula in a cell in a lower row, because I don't want there to be any blanks rows between the two sets of output.
I thought that I could use COUNT or COUNTA to work out how many rows of output there's be from the first Filter formula, but even knowing that, how could I choose in which row the second Filter would begin displaying results?
I thought of using &, but that just puts the first result from each sheet into one cell and gives no other rows or columns of results.
I tried ARRAYFORMULA, but I've never used that before and don't think it is suitable.
I tried JOIN, but it gives an error saying it can only be used for a single row or a single column.
UPDATE: Here's my new code, based on player0's advice
={IFERROR(FILTER('2019 (H904)'!B9:AK, '2019 (H904)'!C9:C=A1, '2019
(H904)'!J9:J=E1), SUBSTITUTE(COLUMN(B9:AK)^0, 1, );
IFERROR(FILTER('2018 (H517)'!B9:AK, '2018 (H517)'!C9:C=A1, '2018
(H517)'!J9:J=E1), SUBSTITUTE(COLUMN(B9:AK)^0, 1, )}))
But I get a formula parse error.
put them in array:
={FILTER(sheet1!A:Z, sheet1!A:A="Bob");
FILTER(sheet2!A:Z, sheet2!A:A="Bob")}
the issue is if one of them outputs nothing. then you need something like this:
=ARRAYFORMULA(QUERY({
IFERROR(FILTER(sheet1!A:Z, sheet1!A:A="Bob"), SUBSTITUTE(COLUMN(A:Z)^0, 1, );
IFERROR(FILTER(sheet2!A:Z, sheet2!A:A="Bob"), SUBSTITUTE(COLUMN(A:Z)^0, 1, )},
"where Col1 is not null", 0))
I'm attempting to automatically populate a Google Sheets column in a "Results" sheet with the following formula, which draws data from a "Source" spreadsheet:
=IFERROR(INDEX(Source!$B$2:$D,MATCH($A2&C$1,Source!$B$2:$B&Source!$C$2:$C,0),3)," ")
When I place that formula in ARRAYFORMULA, it does not auto-populate, and changing the MATCH search_key to a range (i.e., $A2:$A&C$1) does not fix the problem.
I.e., neither of these work:
=ArrayFormula(IFERROR(INDEX(Source!$B$2:$D,MATCH($A2&C$1,Source!$B$2:$B&Source!$C$2:$C,0),3)," "))
=ArrayFormula(IFERROR(INDEX(Source!$B$2:$D,MATCH($A2:$A&C$1,Source!$B$2:$B&Source!$C$2:$C,0),3)," "))
Is there a way to fix this? Or an alternative way to automatically fill a formula? I'm also open to using a function other than INDEX/MATCH, so long as it can do a lookup based on two vertical criteria. Unfortunately I don't think a pivot table would suit my purposes, since my "Results" page also queries another spreadsheet to provide other information.
Example here: https://docs.google.com/spreadsheets/d/1dsaMYsJeZl2o_rNTLwaVhnEehFvAKRMXghAJeEK220s/edit?usp=sharing
This is the formula you are looking for:
=ARRAYFORMULA(IFERROR(HLOOKUP(Source!$D$2,Source!$D$2:$D$11,MATCH($A2:$A4&C$1,ARRAYFORMULA(Source!$B$2:$B&Source!$C$2:$C),0),0),0))
I tested this and it works perfectly fine.
TL;DR
To answer why your formula is wrong,
The second argument in MATCH should have an ARRAYFORMULA otherwise you are basically matching only with first element.
INDEX doesn't work with ARRAYFORMULA. It can only search for a single value in a given range.
The first part can be solved by adding ARRAYFORMULA inside MATCH.
A simple VLOOKUPcould have solved the second problem if you weren't searching for a combination of cells (Date and Name). A twisted HLOOKUP comes to your rescue.
Without the IFERROR part, the formula looks like this:
=ARRAYFORMULA(HLOOKUP(Source!$D$2,Source!$D$2:$D$11,MATCH($A2:$A4&C$1,ARRAYFORMULA(Source!$B$2:$B&Source!$C$2:$C),0),0))
This formula produces the same output (see cell I1):
=QUERY({Source!A:D,ARRAYFORMULA(VLOOKUP(Source!B:B,'Project Lookup'!A:B,2,0))},"select Col2,Col5,sum(Col4) where Col1 is not null group by Col2,Col5 pivot Col3")