Question

I'm trying to use a Google charts query in my spreadsheet to count the number of form responses by a specific person on a given date.

I'm very new to the Google Charts query language (I just started trying to figure it out about an hour ago), but I know SQL so I thought it wouldn't be too hard.

Anyway, here's what my query looks like right now:

=QUERY('Form Responses'!A2:F100, "select count(*) where name = 'Ajedi32' and date timestamp = date '2013-11-19'", {"timestamp", "name", "done", "todo", "blocker", "comment"})

And here's the error I'm getting:

error: Invalid query: Query parse error: Encountered " " * " " * "" at line 1, column 14. Was expecting one of: "min" ... "max" ... "avg" ... "count" ... "sum" ... "no_values" ... "no_format" ... "is" ... "null" ... "year" ... "month" ... "day" ... "hour" ... "minute" ... "second" ... "millisecond" ... "with" ... "contains" ... "starts" ... "ends" ... "matches" ... "like" ... "now" ... "dateDiff" ... "quarter" ... "lower" ... "upper" ... "dayOfWeek" ... "toDate" ... ... ...

I don't get it. Why would it be expecting a function name instead of *?

Was it helpful?

Solution 2

Ultimately, I ended up avoiding the query function entirely by using the filter function instead:

=COUNT(FILTER('Form Responses'!$A$1:$F$100; DATEVALUE('Form Responses'!$A1:$A100)=DATEVALUE('2013-11-19'); 'Form Responses'!$B1:$B100='Ajedi32'))

Expanded for readability:

=COUNT(
  FILTER(
    'Form Responses'!$A$1:$F$100;
    DATEVALUE('Form Responses'!$A1:$A100)=DATEVALUE('2013-11-19');
    'Form Responses'!$B1:$B100='Ajedi32'
  )
)

(If anyone still wants to have a go at answering my original question, feel free.)

OTHER TIPS

I think the problem is likely that count(*) is not a valid construct in the Query language. Try using a column name instead of *.

[edit - answer pertains to a different API; new answer below]

After reading over some questions from other users (link1, link2, [link3(Google spreadsheet Query Error - column doesn't exist)), it seems like the QUERY function does not support the use of column names. You can either refer to columns by letter:

=QUERY($A$1:$C$10, 'select A, B, C');

or by column index in the selected range:

=QUERY($A$1:$C$10, 'select col1, col2, col3');

Try that and see if addressing your columns by letter or index works.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top