Total Sales YTD by Customer

You could do this with a Pivot query.

Create a new query (Sub Query 1). Leave blank for now
Add another Sub Query (Sub Query 2)
Add the following tables

image

Link Customer to InvHead on Company and Customer Number
Link InvcHead to InvcDtl on Company and Invoice number

Add the following fields
image

Calculated Fields
InvMonth DatePart(Month,InvcHead.InvoiceDate)
InvYear DatePart(Year,InvcHead.InvoiceDate)
YearTotal Sum(InvcDtl.ExtPrice)OVER(PARTITION BY Customer.CustID,InvYear)

Go back to Sub Query 1 and add Sub Query 2
image

Right click on Sub Query 2 and set Pivot
image

Set the Pivot field to InvMonth
Add Months 01 thru 12 (Need to have the leading 0)
image

Set your Aggregate Formula to InvDtl_ExtPrice
image

Add your field to Sub Query 1
image

Run your Query

5 Likes