Hello,
Apologies if this is answered elsewhere. I have a database with potentially multiple records per person. My goal is to collapse this down to a single record per person. Here is a sample of the data:
I am trying calculate a new field at the name level for each year the person attended. The code I have for that is as follows:
=IIf(([Tbl_Attendance].[session 1] is not null or [Tbl_Attendance].[session 2] is not null) and [Tbl_Attendance].[year] = 1970,"X"," ") as A70,
=IIf(([Tbl_Attendance].[session 1] is not null or [Tbl_Attendance].[session 2] is not null) and [Tbl_Attendance].[year] = 1971,"X"," ") as A71,
=IIf(([Tbl_Attendance].[session 1] is not null or [Tbl_Attendance].[session 2] is not null) and [Tbl_Attendance].[year] = 1972,"X"," ") as A72,
=IIf(([Tbl_Attendance].[session 1] is not null or [Tbl_Attendance].[session 2] is not null) and [Tbl_Attendance].[year] = 1973,"X"," ") as A73,
=IIf(([Tbl_Attendance].[session 1] is not null or [Tbl_Attendance].[session 2] is not null) and [Tbl_Attendance].[year] = 1974,"X"," ") as A74,
=IIf(([Tbl_Attendance].[session 1] is not null or [Tbl_Attendance].[session 2] is not null) and [Tbl_Attendance].[year] = 1975,"X"," ") as A75,
=IIf(([Tbl_Attendance].[session 1] is not null or [Tbl_Attendance].[session 2] is not null) and [Tbl_Attendance].[year] = 1976,"X"," ") as A76,
=IIf(([Tbl_Attendance].[session 1] is not null or [Tbl_Attendance].[session 2] is not null) and [Tbl_Attendance].[year] = 1977,"X"," ") as A77,
=IIf(([Tbl_Attendance].[session 1] is not null or [Tbl_Attendance].[session 2] is not null) and [Tbl_Attendance].[year] = 1978,"X"," ") as A78,
=IIf(([Tbl_Attendance].[session 1] is not null or [Tbl_Attendance].[session 2] is not null) and [Tbl_Attendance].[year] = 1979,"X"," ") as A79,
I would like a result as follows (remember, one record per person):
LAST NAME FIRST NAME A70 A71 A71 A73 A74 A75 A76 A77 A78 A79
ABRAMS MARK X X X X X
I have tried a few things, but I cannot get it to collapse down to a single record. When I add a GROUP BY clause, it does not like that I am excluding some of the fields used in the calculation and it gives me a run-time error.
Thanks for your help!