supportsvc
Technical User
I can't figure out how to display the YTD totals with the Mth1, Mth2, Mth3 to display the previous quarter totals
This is what I have so far
This produces:
CompanyCode Mth1 Mth2 Mth3 Q1 Q2 Q3 Q4 YTD PrevQtr Year Quarter
054 $4,166.68 $4,166.68 $4,166.68 $12,500.04 $0.00 $0.00 $0.00 $12,500.04 $0.00 2020 1
054 $4,166.68 $4,166.68 $4,166.68 $0.00 $12,500.04 $0.00 $0.00 $12,500.04 $12,500.04 2020 2
Instead of multiple rows, how do you display Mth1-Mth3 for the previous quarter and the YTD? Where they need to report the previous quarter totals with the YTD totals
Did that make sense?
This is what I have so far
Code:
SELECT tblEmployees.CompanyCode, tblEmployees.DepartmentNo, tblEmployees.EmployeeNo, tblEmployees.LastName, tblEmployees.FirstName, tblEmployees.SocialSecurityNo, tblCheckHistory.TaxGroup, tblEmployees.ResidenceTaxStateCode, tblCheckHistory.FilingStatus, Sum(IIf(((Month([CheckDate])-1) Mod 3)+1=1,[WagesSubjToEmployerUI],0)) AS Mth1, Sum(IIf(((Month([CheckDate])-1) Mod 3)+1=2,[WagesSubjToEmployerUI],0)) AS Mth2, Sum(IIf(((Month([CheckDate])-1) Mod 3)+1=3,[WagesSubjToEmployerUI],0)) AS Mth3, Sum(IIf(Month([CheckDate]) In (1,2,3),[WagesSubjToEmployerUI],0)) AS Q1, Sum(IIf(Month([CheckDate]) In (4,5,6),[WagesSubjToEmployerUI],0)) AS Q2, Sum(IIf(Month([CheckDate]) In (7,8,9),[WagesSubjToEmployerUI],0)) AS Q3, Sum(IIf(Month([CheckDate]) In (10,11,12),[WagesSubjToEmployerUI],0)) AS Q4, Sum(IIf(Month([CheckDate]) In (1,2,3,4,5,6,7,8,9,10,11,12),[WagesSubjToEmployerUI],0)) AS YTD, Sum(Abs(Format(DateAdd("q",-1,Date()),"yyyyq")=Format(DateSerial(Year([CheckDate]),Month([CheckDate]),1),"yyyyq"))*[WagesSubjToEmployerUI]) AS PrevQtr, Year([CheckDate]) AS [Year], DatePart("q",[CheckDate]) AS Quarter
FROM tblEmployees INNER JOIN tblCheckHistory ON (tblEmployees.CompanyCode = tblCheckHistory.CompanyCode) AND (tblEmployees.EmployeeNo = tblCheckHistory.EmployeeNo) AND (tblEmployees.DepartmentNo = tblCheckHistory.DepartmentNo)
WHERE (((tblCheckHistory.TaxGroup)=[Forms]![frmProcessing]![StateForProc]) AND ((tblCheckHistory.ResidenceTaxStateCode)=[Forms]![frmProcessing]![StateForProc]))
GROUP BY tblEmployees.CompanyCode, tblEmployees.DepartmentNo, tblEmployees.EmployeeNo, tblEmployees.LastName, tblEmployees.FirstName, tblEmployees.SocialSecurityNo, tblCheckHistory.TaxGroup, tblEmployees.ResidenceTaxStateCode, tblCheckHistory.FilingStatus, Year([CheckDate]), DatePart("q",[CheckDate])
HAVING (((Year([CheckDate]))=[Forms]![frmProcessing]![CurrentYear]));
This produces:
CompanyCode Mth1 Mth2 Mth3 Q1 Q2 Q3 Q4 YTD PrevQtr Year Quarter
054 $4,166.68 $4,166.68 $4,166.68 $12,500.04 $0.00 $0.00 $0.00 $12,500.04 $0.00 2020 1
054 $4,166.68 $4,166.68 $4,166.68 $0.00 $12,500.04 $0.00 $0.00 $12,500.04 $12,500.04 2020 2
Instead of multiple rows, how do you display Mth1-Mth3 for the previous quarter and the YTD? Where they need to report the previous quarter totals with the YTD totals
Did that make sense?