(Google sheets) Query and return multiple tables from url inject - google-sheets

I use the JSON data from a Google spreadsheet, for 2 mobile applications (iOS and Android). The same information can be outputted using HTML or XML, in this case I am using HTML so the information shown (from the spreadsheet) can be understood by everyone. The only logical way to do this is without Authentication (O’Auth) is through public URL Injects. Information about what I’m talking can be found here. In order to understand what I’m asking, you have to actually click the links and see for yourself. I do not know what to “call” some of the things I’m asking as Google’s documation is poor, no fault of my own.
In my app I have a search feature that queries the spreadsheet (USING A URL REQUEST) along the lines of this,
https://docs.google.com/spreadsheets/d/1yyHaR2wihF8gLf40k1jrPfzTZ9uKWJKRmFSB519X8Bc/gviz/tq?tqx=out:html&tq=select+A,B,C,D,E+where+(B+contains"Cat")&gid=0
I select my columns (A, B, C, D, and, E) and ask (Google) that only the rows where column B contains the word cat be return. Again I’m stressing the point that this is done via a URL address (inject being the proper term). I CANNOT use almost any function/formulas that would normally work within a spreadsheet like, ArrayFormula or ImportRange. In fact I only access to 10 language clauses (Read link from before). I have a rather well knowledge of spreadsheets and databases, and as the URL method of getting information from them is similar they are in NO way the same thing.
Now, I would like to point out this part within the URL
tq?tqx=out:html&tq=select+A,B,C,D,E+where+(B+contains"Cat")&gid=0
Type of output, HTML in this case
tqx=out:html
The start of query
&tq=
Select columns A-E
select+A,B,C,D,E
For returning specific information about Cat
where+(B+contains"Cat")
This is probably the most important part of my question. This is used for specifying what table (Tab) is being queried.
&gid=0
If the gid is changed from gid=0 to gid=181437435 the data returned is from the spreadsheets second table. Instead of having to make 2 requests to search both tables is there a way to do both in one request? (like combining the 2) <— THIS IS WHAT I’M ASKING.
There is a AND clause that I have tried all over the url
select+A,B,C,D,E+where+(B+contains%20"Cat")&gid=181437435+AND+select+A,B,C,D,E+where+(B+contains%20"Cat")&gid=0
I have even flipped the gid around and put in other places but it seems to only go by the last one (gid) in the url, and no matter what is done only 1 table is returned. Grouping is allowed by the way. If that doesn’t clear my question up then let me know where you’re lost. Also I would have posted more URLs for easy access but I am kind of on this 2 URL maximum program.

If I understand your requirement, indeed it is, with syntax like this for example:
=ArrayFormula(QUERY({Sheet1!A1:C4;Sheet2!B1:D4},"select * order by Col1 desc"))
The ; stacks one array above the other (, for side by side).
My confusions is with "URL Query Language" as what here is called Google Query Language (there is even the tag though IMO almost all those Qs belong on Web Applications - including this one, by my understanding!) is not confined to use with URLs.
In the example above the sheet references might be replaced with data import functions.

Related

Trying to index match information from 1 google sheet to another

I have the following 2 google sheets
TEST 1
https://docs.google.com/spreadsheets/d/1mAssNMTGXcMcuYhjDWq6lNfWOdgUfI6FbGSWushGAMg/edit?usp=sharing
TEST 2
https://docs.google.com/spreadsheets/d/15PAI8nnTzp1wQuvvkHxZ81kkeRrqHrvUH1vXiF9tya0/edit?usp=sharing
In Test 2 in cells B36,B37 and C36,C37 I am trying to grab information from TEST 1 to TEST 2
I have checked and checked and triple checked but I am not sure why it is not grabbing the information over.
Previously I had used "-" and "( )" in the table names so I decided to remove all of those and use only letters but it is still not working.
I also noticed that it was grabbing from the correct column (in my original google sheet), column D but it was grabbing the wrong information.
But I checked the name I was using to match "Room BS Harvest" and made sure it matched in both google sheets but still was not able to get it to work.
I have turned on show formula so you can see that I have formulas in Test 2 B36,B37,C36,C37
If you have any idea why it is not working please do let me know. I can't figure out why it is not getting the data over.
I myself would not approach things the way you are doing in this sheet. (I always recommend using a separate sheet within your destination spreadsheet where IMPORTRANGE brings in all of the data from the source location, and then using that single sheet in the destination spreadsheet as the reference for all other formulas, such as the ones you're trying to use.)
In addition, your sheets are inaccessible (i.e., "Comment only"). So neither I nor anyone else would be able to setup an alternative method for you to consider.
That said, and working with what you do have, here is how you might adjust the B36 formula...
Here is the formula you originally wrote (and which is not working):
=INDEX(importrange("https://docs.google.com/spreadsheets/d/1mAssNMTGXcMcuYhjDWq6lNfWOdgUfI6FbGSWushGAMg/edit#gid=0",$J$1&"!A4:H26"),MATCH($A36,index(importrange("https://docs.google.com/spreadsheets/d/1mAssNMTGXcMcuYhjDWq6lNfWOdgUfI6FbGSWushGAMg/edit#gid=0",$J$1&"!A4:A26"))),match($J$2,index(importrange("https://docs.google.com/spreadsheets/d/1mAssNMTGXcMcuYhjDWq6lNfWOdgUfI6FbGSWushGAMg/edit#gid=0",$J$1&"!A4:H4"))))
Here is my edit to that formula structure (which should work):
=INDEX(IMPORTRANGE("1mAssNMTGXcMcuYhjDWq6lNfWOdgUfI6FbGSWushGAMg",$J$1&"!A4:H26"),MATCH($A36,IMPORTRANGE("1mAssNMTGXcMcuYhjDWq6lNfWOdgUfI6FbGSWushGAMg",$J$1&"!A4:A26"),0),MATCH($J$2,index(IMPORTRANGE("1mAssNMTGXcMcuYhjDWq6lNfWOdgUfI6FbGSWushGAMg",$J$1&"!A4:H4")),0))
Notice that you only need the spreadsheets ID number for IMPORTRANGE, not the entire URL. This just makes reading such formulas easier.
You also had mismatched sets of parentheses. This was your biggest issue.
And I recommend using the third parameter of MATCH to indicate what kind of match you're looking for. (Here, I assigned 0, which means "exact match only.")
Hopefully, you can use that as a model for editing your other formulas.

OR Operator in Google Sheets Not Working?

This is the formula I am working on right now:
=FILTER(Data!A:K, SEARCH("Gretsch", Data!F:F)+SEARCH("Krutz", Data!F:F))
I'm trying to bring in both rows that include "Gretsch" and rows that include "Krutz". Just using one of those instead of both works just fine, and using keywords that the other has included in it's results (for example, searching just Gretsch brings up 10 or so (out of the 100+) products that include "Streamliner" in the F Column, as well as Gretsch, so using this formula:
=FILTER(Data!A:K, SEARCH("Gretsch", Data!F:F)+SEARCH("Streamliner", Data!F:F))
brings up the 10 or so products with both, but I'm looking for one OR the other, so why is that '+' acting like an AND operator instead? Am I just completely off base?
SEARCH returns a number: the starting position where a string is found within another string. It's not a simple 1 like other tests for TRUE, and there is no 0 case (i.e., FALSE) as you have it written. In addition, if either SEARCH does not find the target string, it returns an error; and a number plus an error... returns an error (which is not TRUE and therefore will not be included in the FILTER).
A better approach to achieving OR with FILTER:
=FILTER(Data!A:K, REGEXMATCH(LOWER(Data!F:F),"gretsch|krutz"))
The pipe symbol ("|") means OR in this context, and you may list as many pipe-separated strings as you like. Notice that the search range is wrapped in LOWER and that the terms to search are also lowercase; this assures the same kind of caps-agnostic search you were looking for with SEARCH.
By the way, based on your other recent post, you can also use REGEXMATCH with NOT, e.g.:
=FILTER(Data!A:K, REGEXMATCH(LOWER(Data!F:F),"gretsch|krutz"), NOT(REGEXMATCH(LOWER(Data!F:F),"case")))
One additional note: Your post is tagged "Excel" and "Google Sheets." The formulas I've proposed will only work with Google Sheets. In most cases by far, it is best to tag a post here with either "Excel" or "Google Sheets" but not both, since the differences are substantial between the two.
try:
=QUERY(Data!A:K, "where lower(F) contains 'gretsch'
or lower(F) contains 'krutz'")

Google data studio - Use multiple datasheet with same data keys/headers

So I've been stuck in this for some days, tryed a lot of search terms but all of them seems to bring me the same answers and i really need this:
I have a demand to join two different company's datas from the same owner, all of them have the same data sources (excel data sheets from FB ADS).
So they all share the same (keys/headers), like this:
COMPANY(1)'S ADS DATA
COMPANY(2)'S ADS DATA
So this way I need to put then togheter without having to join both of then on excel every time and also give him some nice data manipulation power.
The results should be something like this
By now I was trying to join data from the two companys but I couldn't really figure out how to properly do this so far I've made some tests and tryed reading a couple of articles and google data studio's help files. The merging data function seems to mess everything.
As a result of this merge, GDS gives me this fields:
Shouldn't I see like only one field labeled as cnt and cmp? I've noticed that GDS creates not one, but two data fields. If I try adding all data I need as key the left sheet turns all "0s". What Am I doing wrong here?
I have read your descriptions. It seems that you are looking for a solution to append both tables instead of merging the tables.
Do note that the data blending in GDS is a left outer join.
Hence, instead of doing the blending in GDS, I'd suggest you to append both datasets in Google Sheet in a separate tab before importing to GDS for visualisation. (assuming you don't mind copy-pasting the data into the Google Sheet).
Here is the formula to append both datasets in Google Sheets:
= {QUERY(A!A1:D1000,"SELECT A,B,C,D WHERE A <> ''",1);QUERY(B!A2:D, "SELECT A,B,C,D WHERE A <> '' ")}
I've created some dummy data in this google sheets and appended the data using the formula provided , you may take a look to understand further.
If you are unclear on the difference between merge and append, you may take a look in the Google Sheet documentation as well.
On a side note, I've screencast the process of answering this question and posted on my youtube channel. You may take a look if needed. (Thanks for the question and inspiration you provided for the video)

Google Sheets import multiple HTML table images

Summary
I'm looking to import a data table from a website that does not appear to have an API. The table is broken down to various images and text. The goal is to have all of the content available in a table to then reference for other sheets.
Issue
When I pull in the data, I get some of the text, none of the other images, and a reference to another table. I looked up some options, but none of them yielded anything but blank cells.
I also tried to use the =IMAGE() formula with a direct link to the images URLs, but there is a portion of the URL that is specific to the unit's release date, and as such, too dynamic to account for.
Excel Formula
=IMPORTHTML("https://gamepress.gg/pokemonmasters/database/sync-pair-list","table",3)
Unfortunately without an API it is going to be difficult to achieve what you aim here. These are the main reasons why:
PROBLEMS AND WORKAROUNDS
This table has nested tables that therefore need to be accessed separately. If you take a look at: =IMPORTHTML("https://gamepress.gg/pokemonmasters/database/sync-pair-list","table",4)
you will see how the table 4 of this HTML page is the stats of a random character of the main table. If you go for 5 or 6 you will realise that the nested tables are not even numerically ordered and that you cannot access them by accessing to the main table (i.e mainTable[0].nestedTable). A hard working approach to do this is to go one by one finding their corresponding stat table and placing next to it. For this I recommend extracting only the name field of the main table to be able to align each stat to their character. You can simply do this using:=INDEX(IMPORTHTML("https://gamepress.gg/pokemonmasters/database/sync-pair-list","table",3),0,1). You can find out more about INDEX here
IMPORTHTML cannot access images nor links so it will be very difficult to get the images in the last columns. A way to solve this is by using as you mentioned the image with its url like this: =IMAGE("https://gamepress.gg/pokemonmasters/sites/pokemonmasters/files/styles/30x30/public/2019-07/Electric.png?itok=fkRfkrFX"). You can find more info about inserting images here
CONCLUSION
To sum up, there is no easy way to solve this problem. The closest you can get is by:
Importing the name column.
Figuring out which tables belong to which character and placing them with next to their name.
Getting the image url of each weakness and type and add it to each character.
I am sorry this site does not have an API to make things smooth, good luck with your project and let me know if you need anything else or if you did not understand anything.
Here you can find more information about IMPORTHTML

Creating Dynamic Sheet Cell Reference List for pulling numbers to SUM

I've been working on building a data analysis sheet, which is quite verbose at the moment and a bit more complicated than it should be as I've been trying to figure this out. Please note, I work doing student data in a school.
Basically, I have two sets of input data:
Data imported from a CSV file that includes test data and codes for Common Core Standards and the questions tied to those standards as a whole class summary
Data imported from a CSV file that includes individual scores by question
I am looking to construct 2 views:
A view that collates and displays data of individual standards per student that includes a dropdown to change the standard allowing a teacher to see class performance by standard in a broad view. The drop-down is populated dynamically from the input data (so staff could eventually dump data and go directly to reports)
A view that collates and displays data of individual students broken down by performance on each standard allowing a teachers to see the broader spectrum for each student. The student drop-down is populated from Source list 2.
I have been able to build the first view, but am struggling with the second. I've been able to separate the question codes and develop strings of cell references to the scoring data, including a dynamic reference to the row the selected student's score data appears on in the second source set from above.
I tried to pass through an indirect() formula into a sum() so as to process for a mean evaluation, and have encountered errors. I think SUM() doesn't process comma-separated cell reference lists from Indirect() [or in general] or there is something that I am missing to help parse it. Here is the formula I have tried:
=Sum(vlookup(D7,CCCodeManip!$A:$C,3,false))
CCCodeManip!C:C includes the created text (based on the dynamic standards and question codes, etc), here's an example of what would be found there:
'M-ADI'!M17, 'M-ADI'!N17, 'M-ADI'!O17, 'M-ADI'!P17, 'M-ADI'!Q17, 'M-ADI'!R17, 'M-ADI'!J17
I need these to be dynamic so that teachers can input different sets of standards, question, and student data and the sheet automatically collates and reports it in uniform ways (with an upward bound of 20 standards as I currently have it built)
Here is a link to the sheet I built, with names and ID anonymized. There's a CRAP TON of sub-tabs, and that's really just being able to split apart and re-combine data neatly without things error-ing out due to data overlapping, aside from a few different attempts and different approaches to parse the cell reference strings.
The first two tabs are the current status of the data views. I plan to hide a bunch of the functional stuff that is there to help pull data accurately.
The 3rd and 4th tab are the source data sets. 5th is a modified version of source data that allows me to reference things better, and I've tried to arrange the sheets most relevant towards the front of the set.
https://docs.google.com/spreadsheets/d/1fR_2n60lenxkvjZSzp2VDGyTUO6l-3wzwaV4P-IQ_5Y/edit?usp=sharing
Some have a different approach? I am aware that I might be as far as I cn go with this and perhaps should consider scripts - my coding experience is a bit out of date and my strength is more with the formulas, but I can dig into things with some direction, if anyone can help.
Ok so I noticed something.
It seems the failure is in the indirect reference:
=indirect(CCCodeManip!C3)
The string I am trying to parse via indirect is going to be generated into something like this, dynamic from reference to other data:
'M-ADI'!M17, 'M-ADI'!N17, 'M-ADI'!O17, 'M-ADI'!P17, 'M-ADI'!Q17, 'M-ADI'!R17, 'M-ADI'!J17
The indirect returns the error that the above string is not a cell reference with the #REF code.
Can someone give me a clue as to what is causing this? I am going to dig into the docs on Indirect() from google and will post anything that I find.
Perhaps it is that indirect() can't handle lists, but only specific references and arrays, which may require me a to build a sheet to do the SUM formula on for each question set (?)
So I think I figured it out, but i Ended up parsing the data differently, basically doing the sum based on individual cell references and a separate sum formula, bypassing the need to do it all at once, it jsut makes my sheets a lot dirtier! I am eventually going to see if code could do it better if I need to, but this is closed for now.
Basically, I did individual cell references to recall scores in a row, then used a separate SUM formula, and created references / structures to be able to pull those sum() results. Achieves the same end, but with extra crap on the sheet.

Resources