Import multiple data on one cell - arrays

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)), "×")), ",$", ))

Related

What is the best way for refactoring excel formula

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})

Formula to make the outputs of two separate Filter functions display consecutively

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))

Index Match Array formula not working properly

I am completely stumped with an array formula that will not work. I have researched and tried many different things and continue to get the #N/A error. I am hoping someone here can help me understand.
I have a database of employee skills in a table named "Skills" with three columns. Employee ID, Type and Skill Picture of table
On another tab I am trying to run an Index Match array to filter employees that have certain skills. I would like to be able to use 1 or more criteria. For example employees that have the skill "Infor" and "syspro" The criteria is in cell A2 and C2
I am attempting to use the following formulas to do this and they are not working. And I am pressing ctrl+shift+enter
=INDEX(Skills[Employee ID],MATCH(1,($A$2=Skills[Skill]),0),1)
=INDEX(Skills[Employee ID],MATCH(1,($A$2=Skills[Skill])*($C$2=Skills[Skill]),0),1)
I would still recommend using a filter, but if it must be a formula, this should work for you. Change the A$3:A3 to the cell above where the formula will be posted (so this formula assumes it is going in cell A4 of the second sheet) and copy down:
=IFERROR(INDEX(Skills[Employee ID],MATCH(1,INDEX((COUNTIF(A$3:A3,Skills[Employee ID])=0)*(COUNTIFS(Skills[Employee ID],Skills[Employee ID],Skills[Skill],$A$2)+COUNTIFS(Skills[Employee ID],Skills[Employee ID],Skills[Skill],$C$2)=2),),0)),"")

Trouble with ARRAYFORMULA for auto-filling formulas in Google Sheets

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")

Generate hyperlink from query

My query is not returning the literal cell value, but rather only the visual portion of it.
I've got a google spreadsheet with FirstSheet having my info and then with the use of a query on SecondSheet showing part of the information.
The first column of FirstSheet has a hyperlink for each row in column A such as:
=hyperlink("http://www.google.com/test","My Test")
SecondSheet has a query that pulls that column amongst others such as:
=query('FirstSheet'!A2:C;"select*",0)
The query result only returns the label of the hyperlink but not the link itself or the hyperlink formula. Meaning I see the same text on both sheets but on SecondSheet it's not a link. I hope this makes sense.
I've thought about different ways to accomplish this including some how creating a string from a query to give me what I want, but I'm not sure. Any help would be greatly appreciated.
I solved it by moving the query to B2, selected column A last, putting it into Col C, hid C. I'm then using C with a formula I created in col A and then just pasted that formula down to row 100.
=If (C2="","",hyperlink("http://www.google.com/"&C2,C2))
I would have liked this to be more elegant, but it's good enough for now.

Resources