A
Anand Vaidya
Hello all,
I created a cross tab query, which is running fine, as -
TRANSFORM IIf(Count(tblDaily_Attendance.PK_DailyAttendance_Id)>0,"P","A") AS
CountOfPK_DailyAttendance_Id
SELECT tblEmployees.Name, tblDepartments.Dept_Name
FROM tblDepartments INNER JOIN (tblEmployees INNER JOIN tblDaily_Attendance
ON tblEmployees.PK_Emp_Id = tblDaily_Attendance.FK_Emp_Id) ON
tblDepartments.PK_Dept_Id = tblEmployees.FK_Dept_Id
WHERE (((tblDaily_Attendance.Attendance_Date) Between
Format([forms].[frmReports2].[txtFromDateAtt],"m/d/yyyy") And
Format([forms].[frmReports2].[txtToDateAtt],"m/d/yyyy")))
GROUP BY tblEmployees.Name, tblDepartments.Dept_Name
PIVOT Day([Attendance_Date]) In
(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31);
Now I want to change the transform line such that
if tblDaily_Attendance.Net_Hrs_Worked > 6.30 hrs then the expression value
should be 1
if tblDaily_Attendance.Net_Hrs_Worked > 4.00 hrs and < 6.30 hrs , then 0.5
if tblDaily_Attendance.Net_Hrs_Worked < 4.00 hrs or if the record is not
present for that day (ie record count=0), then 0
so I created a query where the transform part looks something like this -
IIf(Count([tblDaily_Attendance].[PK_DailyAttendance_Id])>0,IIf([tblDaily_Attendance].[Net_Hrs_Worked]>#6:30:00
AM#,1,IIf([tblDaily_Attendance].[Net_Hrs_Worked]<#4:00:00 AM#,0,0.5)),0)
but doesn't work and pops up an error -
"You tried to execute a query that does not include specific expression
'iif(count(tblDaily_Attendance.PK_DailyAttendance_Id)>0,iif(tblDaily_Attendance.Net_Hrs_Worked>#12/30/1899
6:30.0#,1,iif(tblDaily_Attendance.Net_Hrs_Worked<#12/30/1899
4:0:0#,0,0.5)),0)' as part of an aggregate function.
I created a cross tab query, which is running fine, as -
TRANSFORM IIf(Count(tblDaily_Attendance.PK_DailyAttendance_Id)>0,"P","A") AS
CountOfPK_DailyAttendance_Id
SELECT tblEmployees.Name, tblDepartments.Dept_Name
FROM tblDepartments INNER JOIN (tblEmployees INNER JOIN tblDaily_Attendance
ON tblEmployees.PK_Emp_Id = tblDaily_Attendance.FK_Emp_Id) ON
tblDepartments.PK_Dept_Id = tblEmployees.FK_Dept_Id
WHERE (((tblDaily_Attendance.Attendance_Date) Between
Format([forms].[frmReports2].[txtFromDateAtt],"m/d/yyyy") And
Format([forms].[frmReports2].[txtToDateAtt],"m/d/yyyy")))
GROUP BY tblEmployees.Name, tblDepartments.Dept_Name
PIVOT Day([Attendance_Date]) In
(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31);
Now I want to change the transform line such that
if tblDaily_Attendance.Net_Hrs_Worked > 6.30 hrs then the expression value
should be 1
if tblDaily_Attendance.Net_Hrs_Worked > 4.00 hrs and < 6.30 hrs , then 0.5
if tblDaily_Attendance.Net_Hrs_Worked < 4.00 hrs or if the record is not
present for that day (ie record count=0), then 0
so I created a query where the transform part looks something like this -
IIf(Count([tblDaily_Attendance].[PK_DailyAttendance_Id])>0,IIf([tblDaily_Attendance].[Net_Hrs_Worked]>#6:30:00
AM#,1,IIf([tblDaily_Attendance].[Net_Hrs_Worked]<#4:00:00 AM#,0,0.5)),0)
but doesn't work and pops up an error -
"You tried to execute a query that does not include specific expression
'iif(count(tblDaily_Attendance.PK_DailyAttendance_Id)>0,iif(tblDaily_Attendance.Net_Hrs_Worked>#12/30/1899
6:30.0#,1,iif(tblDaily_Attendance.Net_Hrs_Worked<#12/30/1899
4:0:0#,0,0.5)),0)' as part of an aggregate function.