Combine two Functions in Google Sheet as STRING Parameter - google-sheets

I am getting Formula Parse error. Help me with Combining 2 Formula. Here IMPORTRANGE has two String Parameter
=IMPORTRANGE("1Iyxg6vcnAR8zHpJaThfdP7UhdiMwFTbOwrW0l_II83M",QUERY(MAINTAINANCE!A5:K151; "select * where Col7 is not null Order By Col7",0))
Here my second Formula QUERY needs to convert in to string using &" but i dont know how to please help me
I Have Try to Using "& to pass both Functions as STRIG. Because IMPORTRANGE has two Parameter as String For Example..
IMPORTRANGE(URL_ADDRESS,RANGE AS STRING)

this:
=IMPORTRANGE("1Iyxg6vcnAR8zHpJaThfdP7UhdiMwFTbOwrW0l_II83M";
SINGLE(QUERY(MAINTAINANCE!A5:K151; "where Col7 is not null order by Col7"; 0)))
will work but only if output from your QUERY is range or cell. example:
A1
A1:A10
Sheet1!A1:A10

Related

Google Sheet | Excel | Array Formula + CountIf + Partial Text Problem

I'm pretty new with ArrayFormula, have been trying but sometime the formula works, sometimes does not. What I'm trying to do is the combination of ArrayFormula, Countif for searching partial text.
As shown in the worksheet below, there are 10 subjects (column A), each subject has at least one of 4 samples (A,B,C,D) summarized as a string (column B). What I'm trying to do is to find which subject has sample A or B or C or D.
I have tried single formula for each sample, eg cell D3
=IF(COUNTIF($B3,"*"&$D$2&"*")>0,$A3,"")
it returns the correct results. However, when I try arrayformula in cell I3,
=arrayformula(IF(COUNTIF($B3:B,"*"&$D$2&"*")>0,$A3:A,""))
The answers are weird. For example: Subjects (Gamma, Zeta, Eta, Theta) who don't have the sample "A" are shown to have sample "A". And this applies to sample B,C,D too
Not sure what went wrong in here. Here is the link to the worksheet
I wouldn't use Countifs or an array formula. Use filter instead. Put this formula in cell i3.
=Filter(if(REGEXMATCH(B3:B,$D$2),A3:A,""),B3:B<>"")
try:
=INDEX(QUERY(IFERROR(TRIM(SPLIT(FLATTEN(IF(IFERROR(SPLIT(B3:B, ","))="",,
SPLIT(B3:B, ",")&"×"&A3:A)), "×"))),
"select max(Col2) where Col2 is not null group by Col2 pivot Col1"))
or use in row 2 if you want to sort it as in your example:
=INDEX(IFNA(VLOOKUP(A2:A, QUERY(IFERROR(TRIM(SPLIT(FLATTEN(
IF(IFERROR(SPLIT(B3:B, ","))="",,SPLIT(B3:B, ",")&"×"&A3:A)), "×"))),
"select Col2,max(Col2) where Col2 is not null group by Col2
pivot Col1 label Col2'Subjects'"), {2,3,4,5}, 0)))
You can accomplish all four columns of results with a single formula.
Delete all formulas from I3:L3.
Place the following formula into I3:
=ArrayFormula(IF(REGEXMATCH(B3:B,I2:L2),A3:A,))
In plain speech, this read "If anything in B3:B matches a value found in I2:L2, return A3:A in the matching columns(s) at the matching row(s); if not, return null."

Why does my column not exist in Google Sheets? Query error

I'm trying to run a simple query to condense a list of information from a column (which contains a consistent data type), removing blanks. I have the following code:
=query({Z:Z},"select * WHERE NOT Z =''")
This produces the error: Unable to parse query string for Function QUERY parameter 2: NO_COLUMN: Z.
I've encountered similar issues with query elsewhere - for some reason not yet figured out by my brain, my columns somehow don't exist. I've tried using col26, col1, and everything between col1 and col30, to no avail. While I could workaround this particular simple situation with more of a filter() function, I'd like to better understand why my column's aren't computing. I'd appreciate any clarification on this.
Try this:
=query({Z:Z},"select * WHERE Col1 is not null")
When using curly brackets {} instead of normal ones () you can not use the column letters any more but the number of the column.
Example: When you have =query({D1:F10},"select * WHERE Col3 is not null") it means F is not null (D=Col1, E=Col2, F=Col3)
you can either use:
=QUERY({Z:Z}, "where Col1 !=''")
or:
=QUERY(Z:Z, "where Z !=''")

Query returning error Unable to parse query string for Function QUERY parameter 2: NO_COLUMN

I am currently working in the following spreadsheet
https://docs.google.com/spreadsheets/d/13KfjUhWSB-BjGyC1G8f8i8o4SPd1kFFLkjN7D6VY8Lk/edit#gid=993210576
In which I am importing data from another worksheet using IMPORTRANGE, and writing a QUERY to match the cells in column B, which correspond to a specific part number, to their corresponding cut quantity found in Column D of the imported sheet. The query I have written is as follows.
=QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/1kFK-ZW8QjtsLYY5twdoMNTdqobGNWIV8nAFBRdouE28/edit#gid=473793446",
"FABRICATION LOG!A78169:K"), "Select Col3 where Col4 = "&B3&" limit 1", 0)`
And is returning the error message:
Unable to parse query string for Function QUERY parameter 2: NO_COLUMN: WFR332703
I have used ImportRange for the sheet I am linking to in sheet1 of the spreadsheet linked above, and allowed access, so the error is not there.
Sheet1 is there to display the values returned for the IMPORTRANGE so that I can manually look up values I am expecting to get. Now for some of these cells, I expect to not get a value, as these will not be in the sheet I'm importing. But for others, I am expecting a numerical value, which is not being returned. I suspect this may have something to do with the fact that there is a mismatch between Datatypes since the entries in column b are both letters and numbers, but this is only a hunch with no actual facts to back it up. If anyone has any suggestions It'd be greatly appreciated.
first, paste this into some cell and connect you sheets by allowing access:
=IMPORTRANGE("1kFK-ZW8QjtsLYY5twdoMNTdqobGNWIV8nAFBRdouE28", "FABRICATION LOG!A1")
then use the formula:
=QUERY(IMPORTRANGE("1kFK-ZW8QjtsLYY5twdoMNTdqobGNWIV8nAFBRdouE28",
"FABRICATION LOG!A78169:D"),
"select Col3
where Col4 = '"&B3&"'
limit 1", 0)
if cell B3 is number use:
=QUERY(IMPORTRANGE("1kFK-ZW8QjtsLYY5twdoMNTdqobGNWIV8nAFBRdouE28",
"FABRICATION LOG!A78169:D"),
"select Col3
where Col4 = "&B3&"
limit 1", 0)
I came here because I had a query like:
=Query(Data, "select * where i < 70", 1)
What fixed it was changing to:
=Query(Data, "select * where I < 70", 1)
The column in the where clause needs to be upper case if its a letter higher than 'd'.

Using indirect function to refer to a concatenated import ranges for query function

Below is my query function in its original form:
=ArrayFormula(query({importrange("1yqTUmJcL6YxgOpfHS5Pt9nYnmpiqN3tUPQP7-Rp8xis","CPG!A2:L20");importrange("1yqTUmJcL6YxgOpfHS5Pt9nYnmpiqN3tUPQP7-Rp8xis","PUB!A2:L20")},"Select Col5, Sum (Col4) where Col6='' group by Col5 pivot Col7"))
Which I am trying to shorten the formula by using indirect to refer to concatenated import ranges by the following attempt
=ArrayFormula(query(indirect("JOIN!J3"),"Select Col5, Sum (Col4) where Col6='' group by Col5 pivot Col7"))
but come up with this error:
Error
Unable to parse query string for
Function QUERY parameter 2:
NO COLUMN: Col5
The Join!J3 cell contains the value below:
{importrange("1yqTUmJcL6YxgOpfHS5Pt9nYnmpiqN3tUPQP7-Rp8xis","CPG!A2:L20");importrange("1yqTUmJcL6YxgOpfHS5Pt9nYnmpiqN3tUPQP7-Rp8xis","PUB!A2:L20")}
I research various similar question in forums but their answers comes to no solution. Usually it is to use "Select Col1" instead of "Select A" but my formulas are all using Col1, Col2 already. Am doing anything wrong?
I have included some images for further clarification.
The original formula:
The shortening attempt:
The cell value in sheetname: JOIN cell: J3:
The cell value in J3 is actually a pasted value from cell A1:
If I understand correctly, because your formula is now referring to a specific range in the sheet instead of an array of ranges, you will need to use A, B instead of Col1, Col2, etc.
I assume the data produced by cell J3 in the sheet JOIN displays data in J3:U21 (based on the range A2:J20). You need to query all of this, not just the cell containing the formula.
Try the formula below.
(I have made assumptions about what columns the data sits in--please amend where necessary).
=ArrayFormula(query(indirect("JOIN!J3:U21"),"Select N, Sum (M) where O='' group by N pivot P")
EDIT: You seem to be using the same range and ID. You can refer to them using just two cells.
={IMPORTRANGE(D6,"SheetName1"&E6);IMPORTRANGE(D6,"SheetName2"&E6)}

Google sheets - Collecting unique values from several sheets?

I'm in the need of collecting unique values from a specific range in several sheets. Is it possible to combine functions in order to do this?
All sheets look the same regarding column structure.
As of now, my function collects from one sheet and it looks like this:
=unique(filter('Sheet1'!C4:C1000,'Sheet1'!C4:C1000<>""))
This collects unique values from Sheet1 from C4 to C1000 and excludes empty cells. This works awesomely, but I have more sheets that I'd like to merge values from. Any idea?
Basic idea is to combine data, first with help of {}:
= {sheet1C4:C1000;sheet2C4:C1000;sheet3C4:C1000}
The next step is to get rid of empty cells. To do it only once, use query:
= query({sheet1C4:C1000;sheet2C4:C1000;sheet3C4:C1000},
"select Col1 where Col1 <> ''")
And then grab uniques/ The final formula will look like:
= unique (query({sheet1C4:C1000;sheet2C4:C1000;sheet3C4:C1000},
"select Col1 where Col1 <> ''"))
By the way, query string may be shortened to this "where Col1 <> ''" will also work

Resources