Google Sheets has a fantastic built in SQL-like Query function that, when combined with Blink Reports, can instantly answer questions like; what are my total sales by Customer?
The syntax is:
QUERY(data, query, [headers])
The documentation is available at:
https://support.google.com/docs/answer/3093343
You can see live examples by opening our
Blink Reports Template and clicking on the "XeroInv Query" tab/sheet.
A simple example that calculates total sales by Contact (Customer) based on the output of the Blink Reports custom formula XeroInv() is:
=query(XeroInv!$A$11:$AF$999,"select B, sum(I) group by B",-1)
or expand it to exclude blank rows and use your own column labels:
=query(XeroInv!$A$11:$AF$999,"select B, sum(I) where B != '' group by B label B 'Customer', sum(I) 'Total Sales'",-1)
- XeroInv!$A$11:$AF$999 is the location of the data in the spreadsheet which in this case is the results of the XeroInv() formula on the sheet named XeroInv
- "select B, sum(I) where B != '' group by B label B 'Customer', sum(I) 'Total Sales'" is the actual query using Google Visualization API Query Language which is similar to SQL.
- In this example it outputs the Contact from column B and then calculates the sum by Contact of column I.
- where B != '' filters out blank contact records
- label B 'Customer', sum(I) 'Total Sales' provides more friendly column names
- -1 means output 1 or more rows of headers depending on the source data
This formula will produce the output:
Customer | Total Sales |
Bank West | 1299 |
Basket Case | 914.55 |
Bayside Club | 234 |
Boom FM | 1623.75 |
City Agency | 593.23 |
City Limousines | 1191.83 |
DIISR - Small Business Services | 1077.14 |
Hamilton Smith Ltd | 2173.75 |
Marine Systems | 396 |
Petrie McLoud Watson & Associates | 1407.25 |
Port & Philip Freight | 1082.5 |
Rex Media Group | 1632.5 |
Ridgeway University | 12375 |
Young Bros Transport | 1082.5 |
You can also produce pivot tables such as total Sales by customer but split by invoice status across the columns:
=query(XeroInv!$A$11:$AF$999,"select B,sum(I) where B != '' group by B pivot E label B 'Customer',sum(I) 'Total Sales' ",-1)
Which produces a pivot table:
Customer | AUTHORISED Total Sales | PAID Total Sales |
Bank West | | 1299 |
Basket Case | 914.55 | |
Bayside Club | 234 | |
Boom FM | | 1623.75 |
City Agency | | 593.23 |
City Limousines | 1191.83 | |
DIISR - Small Business Services | 838.94 | 238.2 |
Hamilton Smith Ltd | 550 | 1623.75 |
Marine Systems | 396 | |
Petrie McLoud Watson & Associates | | 1407.25 |
Port & Philip Freight | | 1082.5 |
Rex Media Group | 550 | 1082.5 |
Ridgeway University | 6187.5 | 6187.5 |
Young Bros Transport | | 1082.5 |
Unlike Microsoft Excel, this query formula is built in so there are no software plugins or addons to install and keep up to date. Google Sheets make sharing and collaborating on these reports with your team as simple as sending them a web page link since they only need a web browser to view them.
The query formula combined with Blink Reports offers endless possibilities for slicing and dicing your sales or purchase transaction data from your Xero Accounting Software.
Sign up today for a Blink Report free trial at http://www.blinkreports.com/