I am new to exploring the capability of Google Query and am seeking some assistance with structuring my query. I am esentially seeking to generate a table similar to the below, that summarises my income + expenses by month, whilst calculating the amount saved each month and the assoicated savings rate.
={query(Expense_Data, "SELECT C, SUM(Q) where T is not null GROUP BY C PIVOT T ORDER BY C desc limit 3",1),query(Expense_Data, "Select Sum(Q) where T is not null Group by C limit 3 label Sum(Q) 'Savings'")}
| Month (Date) | Expense | Income | Savings | Savings Rate (NEED ASSISTANCE) % |
|---|---|---|---|---|
| 01/05/2021 | -1000.00 | 1500.00 | 500.00 | 33.33% |
| 01/04/2021 | -1000.00 | 1500.00 | 500.00 | 33.33% |
| 01/03/2021 | -1000.00 | 1500.00 | 500.00 | 33.33% |
My dual query below so far does the job for the first 3 columns, however I am unsure how to generate the 'Savings Rate' considering this query would requre (I'm guessing) an arthimetic operator except these would contain different 'where' conditions. (ie SELECT SUM(Q) / SUM(Q) where T = 'Income')??
Any help would be greatly appreciated.
Cheers
