Search code examples
google-apps-scriptgoogle-sheetsgoogle-visualizationgoogle-sheets-querygoogle-query-language

How to make a WHERE query for Google Charts?


I'm playing around with Google Charts and some sample data in Google Sheets. I can draw a basic chart but having issues with doing a WHERE query. Can't really find any good documentation or samples either, strangely enough.

Anyway, trying to do this:

    var queryString = encodeURIComponent("SELECT A WHERE B='Mag A', SUM(C) GROUP BY B");

  var query = new google.visualization.Query('dataurl?headers=1&tq=' + queryString);

and can't figure out how to write the query to get it right.

The issue can be seen here: https://codepen.io/paperhack/pen/JgbXwN


Solution

  • the syntax should be in order like:

    "SELECT A,SUM(C) WHERE B='Mag A' GROUP BY A"