Concatenate or join of dynamic array when importing multiple ranges - arrays

I have a set of hyperlinks to other sheets that will change as new links are added or subtracted. I am looking to write a function that will import the same range from all of these sheets. The sheets are all based on the same template.
I am able to create the dynamic range using the following:
C1 ="B1:B"&counta(B1:B)
I then join everything with this formula here:
="{importrange("&join(", """&"Sheet1!A:A"&"""); importrange(",indirect(C1))&", """&"Sheet1!A:A"&""")}"
The output shows what I need the formula to be, however it will not calculate and appears as a string. I tried using indirect on the formula created, however this does not work either as it states indirect requires a valid range.
{importrange(https://docs.google.com/spreadsheets/d/19S08r/, "Sheet1!A:A"); importrange(https://docs.google.com/spreadsheets/d/19S08r/, "Sheet1!A:A"); importrange(https://docs.google.com/spreadsheets/d/1uxdty/, "Sheet1!A:A"); importrange(https://docs.google.com/spreadsheets/d/19S08r/, "Sheet1!A:A")}

Google Sheets built-in functions can't convert a TEXT value into formula. This could be done only by using Google Apps Script or the Google Sheets API.
The method to be used is setFormula / setFormulaR1C1 to return a single formula, and setFormulas / setFormulaR1C1 to return an array of formulas.
NOTE: IMPORTRANGE requires that the first parameter be a TEXT value, so if you will include the URL directly instead of using a cell reference, the URL should be quote enclosed.

Related

Using Google sheets arrays like in Microsoft Excel (ANDING two arrays)

Hello I would like to combine two arrays in google in such a way:
={TRUE,TRUE,FALSE}*{FALSE,TRUE,FALSE}
Where the result should equal: {FALSE,TRUE,FALSE}
In excel that formula listed above works. In google I simply get 0 as the result. What should I enter in google to get the result like I do in excel?
Example in excel I am trying to achieve Excel
Example in Google Sheets: Google Sheets
Tried:
={TRUE,TRUE,FALSE}*{FALSE,TRUE,FALSE}
Expected:
{FALSE,TRUE,FALSE}
use:
=INDEX({TRUE,TRUE,FALSE}*{FALSE,TRUE,FALSE})
and if you want a boolean back do:
=INDEX(TRUE=({TRUE,TRUE,FALSE}*{FALSE,TRUE,FALSE}))
Have you tried simply using ARRAYFORMULA? For example,
=ARRAYFORMULA({TRUE,TRUE,FALSE}*{FALSE,TRUE,FALSE})
Or, if you insist on an array of Booleans:
=ARRAYFORMULA({TRUE,TRUE,FALSE}*{FALSE,TRUE,FALSE}=1)

Compare data from two tabs and get the result Match/Non-Match (Google spreadsheets)

There are two tabs in the Google Spreadsheet.
I need to compare columns B from each tab and identify them as Match/Non-Match
I used Vlookup but for some reasons I does not work.
Here is the link to the file - https://docs.google.com/spreadsheets/d/1CoN2hwj1tmFCiiEJ2iOIkIbIBRRa39N4iOPWr_IGAp0/edit?usp=sharing
=ARRAYFORMULA(IF(B2:B="",,COUNTIF(Staging!B:B,B2:B)>0))
=ARRAYFORMULA(IF(B2:B="",,COUNTIF(Live!B:B,B2:B)>0))

How do I get value of an indirect formula into a format that can go into an array?

My Google Sheet that will be updated over time with new sheets. On my dashboard/master sheet, I can write a simple INDIRECT that will pull information from a cell in the sheets. However, the formula does not replicate its way down the column. I understand that I need to use an ARRAYFORMULA to get the auto formula placement done.
I've tried many ways but the one that I think may get me there is to use CONCAT. My columns look like this:
Event Title [uses a script to pull in the names of all the sheets]
Use an array to get the titles so they pre-poluate down the column so I can use it later: =ARRAYFORMULA(IF(Row(A:A)=1,"Get Title from A",IF(ISBLANK(A:A),"",A:A)))
-- The Event Title is now appearing as plain text in Column B.
I then use CONCAT to write the part of the formula I need to help get the name of the INDIRECT in without using the INDIRECT formula.
=CONCAT("'"&B5&"'"&CHAR(38)&"!"&"""","B2"&"""")
-- This gets me this result: 'Computers 101'&"B2"
At this point, my hope is that I could then use this information ('Computers 101'&"B2") into an ARRAYFORMULA. I used this formula to try and do that:
={"Event Date";ARRAYFORMULA(A6:A+D6:D&"Cat")}
-- I get the answer: 0
The expected value was the date cell (B2) in the Computers 101 sheet. Any ideas how to proceed? I don't know the names of the sheets in advance.
unfortunately, this is not possible within of scope of google sheets formula. if you need ranges from other than the actual sheet you need to use INDIRECT which is not supported under ARRAYFORMULA.
you have 3 options:
hardcode it like: https://stackoverflow.com/a/68446758/5632629 with IFERROR & array of empty cells to match columns of your range
generate formula which will generate your final formula/range as a text string and then use a simple script to convert that string into the valid formula: https://stackoverflow.com/a/61819704/5632629
do it all with scripts

How to return an array matching a certain criteria in Excel?

I'm trying to parse an XML file in Excel, which is a Japanese dictionary. It contains several translations of each entry into different languages, and some entries have multiple translations per language. I want to write a formula that finds all of the translations by their language code, returns them as an array, and concatenates them using a TEXTJOIN formula. But I don't know how to go about this in Excel.
In Google Sheets, this would be easily solved by a FILTER function, but I can't use Sheets as there's too much data, and I haven't managed to get access to the beta FILTER function yet.
In the below picture, I'm trying to return the values in the <gloss xml:lang*> column, by searching for the values in the lang column. So for example, I want to return all values which have a "dut" next to them, and concatenate those into a single line using TEXTJOIN.
Any idea how I could go about doing this?
I fixed this by downloading the FILTER function. This is part of the Office Insider program, which releases Beta features if you choose to participate. You can access the Insider program by going to File > Account > Office Insider. Then to update your Office version go to File > Account > Office Updates to install the Insider update.
To filter the list by the "lang" column the formula looked like:
=FILTER([range in H column], [range in I column]=T$2)
I haven't specified either range because I used a formula-defined range using the INDIRECT function to avoid filtering through a million rows. The H range is what I want in the results of the filter, the I range is what I want to filter by - the "lang" code. T$2 represents the "lang" code, in this case "dut", and when I copy it across it will filter by each of the 8 lang codes in Row 2.
Then I used TEXTJOIN to combine it the array result into one column using the comma separator:
=TEXTJOIN(", ", TRUE, FILTER(...))

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

Resources