supportsvc
Technical User
I can't figure out how to display records with $0 but with YTD totals when there's no data in the selected quarter
Here's the query
The form has 3 for the Quarter and 2020 for the Year
Since the end goal is to report on all companies and employees of the reporting year on a quarterly basis, when a companies and employees don't have any data for a quarter, it doesn't show any data when a criteria is set for the Quarter in the query. Having removed it, it shows all quarters of the reporting quarter.
Example: Need to report on quarter 3 of wages paid in quarter 3 PLUS the YTD wages paid by ALL Companies and Employees.
Having the criteria to show the quarter 3 totals excludes YTD data for companies that didn't have any wages in quarter 3. But the report needs to show ALL companies and employees of the reporting year.
see this
CompanyCode = 288 has data in Quarters 1 and 2 but not in 3 so with the criteria to report on Quarter 3 data, this company's YTD won't show.
Hopefully this made sense and someone can help me.
Here's the query
The form has 3 for the Quarter and 2020 for the Year
Since the end goal is to report on all companies and employees of the reporting year on a quarterly basis, when a companies and employees don't have any data for a quarter, it doesn't show any data when a criteria is set for the Quarter in the query. Having removed it, it shows all quarters of the reporting quarter.
Example: Need to report on quarter 3 of wages paid in quarter 3 PLUS the YTD wages paid by ALL Companies and Employees.
Having the criteria to show the quarter 3 totals excludes YTD data for companies that didn't have any wages in quarter 3. But the report needs to show ALL companies and employees of the reporting year.
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 PreQtr, Sum(IIf(DatePart("q",[CheckDate])=[Forms]![frmProcessing]![CurrentQuarter],[WagesSubjToEmployerUI],0)) AS PrevQtr, Year([CheckDate]) AS [Year], DatePart("q",[CheckDate]) AS Quarter, tblCompanies.ProcessIt
FROM (tblEmployees INNER JOIN tblCheckHistory ON (tblEmployees.DepartmentNo = tblCheckHistory.DepartmentNo) AND (tblEmployees.EmployeeNo = tblCheckHistory.EmployeeNo) AND (tblEmployees.CompanyCode = tblCheckHistory.CompanyCode)) INNER JOIN tblCompanies ON (tblCheckHistory.CompanyCode = tblCompanies.DRCode) AND (tblEmployees.CompanyCode = tblCompanies.DRCode) AND (tblCheckHistory.CompanyCode = tblCompanies.DRCode)
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]), tblCompanies.ProcessIt
HAVING (((Year([CheckDate]))=[Forms]![frmProcessing]![CurrentYear]) AND ((tblCompanies.ProcessIt)=True));
see this
CompanyCode = 288 has data in Quarters 1 and 2 but not in 3 so with the criteria to report on Quarter 3 data, this company's YTD won't show.
Hopefully this made sense and someone can help me.