Google Sheets – Query Using Week Number to Order Dates

google sheetsgoogle-sheets-datesgoogle-sheets-query

I was finishing ordering timestamps and dates, and I can't quite get it to work:

=QUERY(Sheet3!A:I, "
SELECT D, SUM(I)
  GROUP BY WEEKNUM(D) ORDER BY D DESC
  LABEL SUM(I) 'Balance Semanal'
        SUM(I) '$#,##0.00'")

Please let me know your thoughts on how to fix this.

Best Answer

You cannot use WEEKNUM as a clause in a query.

Please use the following formula instead:

=QUERY({ARRAYFORMULA(WEEKNUM(Sheet3!D1:D)),Sheet3!I1:I} ,
" SELECT Col1, SUM(Col2) GROUP BY Col1 ORDER BY Col1 DESC OFFSET 1 LABEL Col1 'Semanal', SUM(Col2) 'Balance Semanal'format SUM(Col2) '$#,##0.00'")