Search code examples
google-sheetsgoogle-sheets-query

Weird result of QUERY in google spreadsheets


I have exported some data out of a budgeting app I'm using and wanted to get some insight into it using google sheets. I've anonymized the data and set up a smaller sample here:

https://docs.google.com/spreadsheets/d/1VKNrwugDW7IXxa_k3nuj6YAjZhz_3R8OaYeFLs7PNpE/edit?usp=sharing

The first sheet - "Export" - contains the raw export data. On the second sheet - "Expenses" - I would like to have just the expenses, i.e. only the negative values from "Export", but I want them to be positive.

I'm using the following query:

=QUERY(Export!A2:Z,"SELECT G, B, C*-1 WHERE C < 0", 0)

to obtain the subset, and it seems to work fine (all rows taken are correct), but everything seems to be shifted down by one row and I get this weird artifact in the first row:

Weird artifact I'm getting

If I remove the * -1 part, I get the correct data (but it's negative of course).

Any ideas as to what might be causing this?


Solution

  • Please try:

    =QUERY(Export!A2:Z,"SELECT G, B, C*-1 WHERE C < 0 label (C*-1) ''")
    

    The label is automatic - unless removed.