Hi Samuel, You can't use a Query the way you're using it.
Firstly, the query must be sent first, since it's a request to Sheets. It doesn't immediately send when you construct it. You have to do so explicitly via query.send(). Secondly, queries are asynchronous, which means that you have to provide a callback for the result, since it won't be available immediately after a query was sent, but some indeterminate amount of time later. Thirdly, query[1, 1] is not valid JavaScript. And finally, a query will return a JSON object that may be an error or a DataTable, so you'll have to check the response. We have fairly extensive documentation for Query, which you can find here <https://developers.google.com/chart/interactive/docs/queries>. I think you'll have better luck following the documentation examples than trying random things. On Fri, Sep 25, 2015 at 2:08 PM <[email protected]> wrote: > So I do a query to a Google Sheet as Below but I get the whole column. > > How can I get a particular value of that query? > > Let's said that I'm queering this table: > > Name Last Name Age > John Smith 26 > > After I execute the query SELECT B, C WHERE A = John > > I would like to introduce in a variable the values Smith and 26. > > something like: > > var LastName = query [1,1] > var Age = = query [1,2] > > This is what I tried so fat and didn't work: > > var Area = query[0].value; > var Area = query[0]; > var Area = query[1,1].value; > var Area = query[1,1]; > > Code below. > > var dataSourceUrl = ' > https://docs.google.com/spreadsheets/d/1xfb9trifQA5KDPc9Nh5hBL4MJ290Mxcc1Uod2VTPzYI > '; > var magicIncantation = '/gviz/tq?sheet=Sheet1&headers=1&tq='; > > > var queryStringInfo = encodeURIComponent("SELECT C WHERE A = > 'Alabama'"); > query = new google.visualization.Query(dataSourceUrl + > magicIncantation + queryStringInfo); > var Area = query[0].value; > var Area2 = query[1].value; > var Area3 = query[1,1].value; > > *THANK YOU SO MUCH!!!!* > > -- > You received this message because you are subscribed to the Google Groups > "Google Visualization API" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to > [email protected]. > Visit this group at > http://groups.google.com/group/google-visualization-api. > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-visualization-api/572d7d5f-8bba-43f9-b2f9-9d5d5ec70e60%40googlegroups.com > <https://groups.google.com/d/msgid/google-visualization-api/572d7d5f-8bba-43f9-b2f9-9d5d5ec70e60%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-visualization-api. To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/CAEwwup7TZE7BPaukRL8wJOXQ5%2BkXqbzy-nh7w4_bQn4e0tjokQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
