array formula in google sheets - google-sheets

I am creating a source parse for work. I am using the formula:
=ARRAYFORMULA(iferror(split(B2:B,"&fbclid",false,true),"Unknown"))
Sometimes a source will come in with the URL parameter blank which is labeled as Unknown. The issue I am having is that the rows below the data are also rendered as unknown. Each day I will be adding more leads to be parsed, but how do I only show unknown for leads that are being parsed and not for the rows that have nothing at all.

Try
=ARRAYFORMULA(iferror(if(B2:B="",,split(B2:B,"&fbclid",false,true),"Unknown")))

Related

Split ArrayFormula throwing #valueerror when data added to cells in range

Sorry for poor formatting ahead of time.
I have a Google Sheet that collects responses from a Form. What I am trying to do is take the URLs that are made from the file upload question on the form and split them into individual URLs in the same row. I had this working without issue previously and now when making a new sheet, the formula I am using is not working and giving me unexpected errors or data. Can't embed photos yet so links below.
Formula
Value Error
The formula will copy data from the reference cell if there is no comma, but if a comma is added to any cell in the column, the entire formula stops working. I am really not sure what the problem is as I said this worked just fine previously. Thanks in advance, I've been at this longer than I care to admit and I assume this is a simple problem that I have overlooked.
The reason why you encountered such issue is because you are trying to create an array with mismatched number of columns.
Based on your sample scenario, when you used ={"File1";arrayformula(iferror(split(Q2:Q,",")))} while your column Q2:Q data doesn't have a comma, arrayformula will return 1 column results. Row1 column count and the array formula result's column count matches.
But if Q2:Q data contains comma, arrayformula will return multiple column results which doesn't match in your row 1 column count
You can use this formula in cell R1:
=arrayformula(iferror(split({"File1,File2,File3,File4,File5,File6";Q2:Q},",")))
Output:

Google Sheets importXML Returns Empty Value

Im trying to scrape this website (https://kamadan.gwtoolbox.com/) with google sheets for material costs for a game that I play. There are two tables; "Common Materials" and "Rare Materials" in a drop down in the top right corner. I am trying to pull the values for both as the prices update. I copied the full Xpath and used the function below in an empty cell on a sheet.
=importxml("https://kamadan.gwtoolbox.com/","/html/body/div[2]/div[1]/div/div[2]/table/tbody")
This returns a #N/A error saying it is returning an empty value.
I also tried it with the regular xpath...
=importxml("https://kamadan.gwtoolbox.com/","//*[#id='trader-overlay-items']")
Which just returns a blank cell. I have also tried both methods using the inspect function through chrome on the ancestors and children they return either of the two errors above.
Sorry if this is a really easy one. I am not familiar at all with Xpaths or html. I mostly dabble in VBA in excel.
Answer:
IMPORTXML can not retrieve data which is populated by a script, and so using this formula to retrieve data from this table is not possible to do.
More Information:
As you've already mentioned, you can attempt to get the data directly from the table using:
=IMPORTXML("https://kamadan.gwtoolbox.com/","//table[#id='trader-overlay-items']")
Which just gets a blank cell.
I went a step further and tried to reverse-engineer this by calling IMPORTXML on the HTML elements on the page in steps:
=IMPORTXML("https://kamadan.gwtoolbox.com/","html")
=IMPORTXML("https://kamadan.gwtoolbox.com/","html/body")
=IMPORTXML("https://kamadan.gwtoolbox.com/","html/body/div[1]")
=IMPORTXML("https://kamadan.gwtoolbox.com/","html/body/div[1]/div[0]")
...
html/body/div[1]/div[0] is the first path which gives no imported content, and we can see from importing html/body that the full body does not contain the imformation and only a template of it - in cell B1 we have references to 'Common materials' and 'Rare materials':
And in D1 we start to see JavaScript and JSON objects which are not called by IMPORTXML and so the results of which can not be retrieved:
As you can see if you disable JavaScript on the site, almost nothing is actually rendered and so can't be obtained using IMPORTXML:
References:
IMPORTXML - Docs Editors Help

VLOOKUP keeps giving #N/A

I am using VLOOKUP to do some looking up and I have all the values right but it keeps giving me #N/A. Here is what I am doing:
I have a data in 2 columns, Column A has names and column B has ID. I have copy and pasted the some details further down the columns and that is what I am searching. It keeps giving me #N/A when the data it is search is the same data I pasted.
The formula I am using is as follows:
VLOOKUP(B10,A30:B46,1,FALSE)
Any ideas why this is doing it?
When I use TRUE instead it gives me a really wrong match. nowhere close
I found the answer therefore just updating it here.
You can get around the error by using INDEX and MATCH functions. Especially if it includes massive tables and multiple sheets.
I used the following to solve my issue and hope it helps others too.
=INDEX('Users activity volumes'!A7:A367,MATCH('MH Users'!B8,'Users activity volumes'!B7:B367,0))

"Formula parse error" when querying different document

I am attempting to have a cell in Sheet B display data from a cell in External / Remote Sheet A, but it results in "Formula parse error." (ETA detail to aid searches: displaying data in one Google Spreadsheet from a different Google Sheet.)
My query:
=Query(SheetA,sheet1!A:I,"select I WHERE A=3")
I've also tried it this way:
=Query(SheetA,sheet1!$A:$I,"select I WHERE A=3",-1)
This answer courtesy of #AdamL (thank you, sir!). This was his answer that I found does work very well. When QUERY isn't directly referencing a range in the same spreadsheet, use Colx notation rather than column letters:
=QUERY(importrange("NameofGoogleSheet","SheetTabName!A:Z"),"select Col9 where Col1=3")
If referencing dynamically, use something like:
=QUERY(importrange("NameofGoogleSheet","SheetTabName!A:Z"),"select Col9 where Col1="&D19)
It is also important to note that you must first connect the sheets to each other. Until this is done, you will get column errors, etc. This is done by selecting a cell of the sheet that will display the data, and putting in an IMPORTRANGE on it, which opens a dialog for connecting them. More info: https://support.google.com/docs/answer/3093340?hl=en
I also realized (duh) that I was being stupid to have two separate files for each. I only need two sheets within the same document; 1 to serve as the database and the other to display the formatted data. I am using this for a pedigree application.
I had a Formula Parse Error problem. My mistake was that I had two brackets on my formula. I deleted one set, and it was fixed. I am not sure why, but it worked for me.
EXAMPLE:
=SUM((AB450,AB432,AB422,AB415,AB405)) - THIS GAVE ME A FORMULA PARSE ERROR.
=SUM(AB450,AB432,AB422,AB415,AB405) - THIS IS THE ONE THAT WORKED

Unable to use QUERY in google sheets when referencing cell as a value

I am working on a spreadsheet in google sheets that tries to do the following.
Retrieves a table by scraping a website.
Uses a query within that table to retrieve a specific value in the table.
Uses an existing cell in the spreadsheet to determine the value to match.
You can see the spreadsheet here. Cell D2 is the one in question. It attempts to use the C2 value to build a query. It doesn't work for some reason. I believe I have the correct syntax, but I'm not sure. Directly below in Cell D3 is the same formula with the value directly entered rather than referring to the cell.
I am getting an error that says "query completed with an empty output", which doesn't make sense to me when it works with the value directly inputted.
I figured this out, I was using the syntax incorrectly. The correct formula goes like this.
=query(importhtml(B2,"table",1),"select Col4 where Col8 ="&C2,1)
I imagine it was throwing an error because the second & symbol would lead it to believe that more text was coming and there was none.

Resources