In Google Sheets I have multiple positive and negative numeric data entries per each day. I want to create a table using the query function, such that I have the following rows: Date, Negative, Positive, Total.
Date Value
28/07/2016 10
28/07/2016 -0.9
28/07/2016 -20
29/07/2016 -30
29/07/2016 -12
29/07/2016 18
29/07/2016 -3
30/07/2016 7
30/07/2016 7
30/07/2016 15
30/07/2016 -1
30/07/2016 7
It looks like I could do three formulas with query function:
=query(A2:B13,"select A, sum(B) where B < 0 group by A order by A label A 'Date', sum(B) 'Negative'", -1)
=query(A2:B13,"select A, sum(B) where B > 0 group by A order by A label A 'Date', sum(B) 'Positive'", -1)
=query(A2:B13,"select A, sum(B) group by A order by A label A 'Date', sum(B) 'Total'", -1)
but the problem is that I have to select Date every time to be able to group and order by it. If I do not select A, the function returns #VALUE!. So the result looks like this:
Date Negative Date Positive Date Total
28/07/2016 -20.9 28/07/2016 10 28/07/2016 -10.9
29/07/2016 -45 29/07/2016 18 29/07/2016 -27
30/07/2016 -1 30/07/2016 36 30/07/2016 35
Can I somehow avoid selecting Date for Positive and Total? I know I can simply hide these columns, but is there another way?