Forum Discussion
Summarizing and Combing Tables
I'm struggling with combining and summarizing tables. I have 3 related tables. A student table, containing basic student information; a center table which provides the center name, and an attendance table which provides daily student attendance data. The end goal is to: (1) calculate the number of possible attendance days per month per center, (2) calculate the number of days absent per student per month, and (3) combine (1) and (2) to calculate each student's monthly absentee percentage. Below is a sample of the 3 raw data tables and the desired end-result. I'm envisioning doing this by creating calculated tables, but perhaps there is a more effecient method?
Hi Anonymous
Create a column in "Attendance" table
month-year = FORMAT(Attendance[AttendanceDate],"yyyy-mm")
Create measures in "Attendance" table
CountOfAbsenses = CALCULATE ( DISTINCTCOUNT ( Attendance[AttendanceDate] ), FILTER ( ALL ( Attendance ), Attendance[StudentID] = MAX ( Attendance[StudentID] ) && Attendance[Student_Attendance] IN { "Absent (Excused)", "No Show" } ) ) CountOfAttendance = CALCULATE ( DISTINCTCOUNT ( Attendance[AttendanceDate] ), FILTER ( ALL ( Attendance ), Attendance[StudentID] = MAX ( Attendance[StudentID] ) && Attendance[Student_Attendance] <> "Service Day" ) ) flag = IF ( MAX ( Student[StudentID] ) <> BLANK () && MAX ( Student[ProgramType] ) <> "After Hours" && MAX ( Center[CenterID] ) <> BLANK () && MAX ( Attendance[month-year] ) <> BLANK (), 1, 0 ) % = IF ( [CountOfAbsenses] / [CountOfAttendance] = BLANK (), "0%", [CountOfAbsenses] / [CountOfAttendance] )Best Regards
MaggieCommunity Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 Replies
- Greg_DecklerCommunity Champion
Can you post that last table as text? That's a lot of information to type in by hand.
- AnonymousNot applicable
Hi Greg,
Sure. I'm attaching the 3 raw data tables, as well as the end-result table.
Table - Center CenterID CenterName 3001 Baker County 3002 Columbia County Table-Student CenterID StudentID StudentName ProgramType 3001 101 Jane Doe Day 3001 102 Jim Weber Day 3001 103 Ken Adams After Hours 3002 104 Abigail Stevens Day 3002 105 Tenecia Jenkins Day Table-Attendance StudentID AttendanceDate ServiceType Student_Attendance 101 5/1/2019 Daily Attendance Attended 101 5/1/2019 Lunch Attended 102 5/1/2019 Daily Attendance Absent (Excused) 102 5/1/2019 Lunch Absent (Excused) 103 5/1/2019 Daily Attendance Attended 104 5/1/2019 Daily Attendance Attended 104 5/1/2019 Lunch Attended 105 5/1/2019 Daily Attendance No Show 105 5/1/2019 Lunch No Show 101 5/5/2019 Daily Attendance Attended 101 5/5/2019 Lunch Attended 102 5/5/2019 Daily Attendance Attended 102 5/5/2019 Lunch Attended 103 5/5/2019 Daily Attendance Attended 104 5/5/2019 Daily Attendance Attended 104 5/5/2019 Lunch Attended 105 5/5/2019 Daily Attendance Attended 105 5/5/2019 Lunch Attended 101 5/10/2019 Daily Attendance Absent (Excused) 101 5/10/2019 Lunch Absent (Excused) 102 5/10/2019 Daily Attendance Absent (Excused) 102 5/10/2019 Lunch Absent (Excused) 103 5/10/2019 Daily Attendance Attended 104 5/10/2019 Daily Attendance Service Day 105 5/10/2019 Daily Attendance Service Day StudentID StudentName CenterID CenterName Month-Year CountOfAbsenses CountOfAttendanceDates AbsenteePerc 101 Jane Doe 3001 Baker County 2019-05 1 3 33% 102 Jim Weber 3001 Baker County 2019-05 2 3 67% 104 Abigail Stevens 3002 Columbia County 2019-05 0 2 0% 105 Tenecia Jenkins 3002 Columbia County 2019-05 1 2 50% - v-juanli-msftCommunity Support
Hi Anonymous
Create a column in "Attendance" table
month-year = FORMAT(Attendance[AttendanceDate],"yyyy-mm")
Create measures in "Attendance" table
CountOfAbsenses = CALCULATE ( DISTINCTCOUNT ( Attendance[AttendanceDate] ), FILTER ( ALL ( Attendance ), Attendance[StudentID] = MAX ( Attendance[StudentID] ) && Attendance[Student_Attendance] IN { "Absent (Excused)", "No Show" } ) ) CountOfAttendance = CALCULATE ( DISTINCTCOUNT ( Attendance[AttendanceDate] ), FILTER ( ALL ( Attendance ), Attendance[StudentID] = MAX ( Attendance[StudentID] ) && Attendance[Student_Attendance] <> "Service Day" ) ) flag = IF ( MAX ( Student[StudentID] ) <> BLANK () && MAX ( Student[ProgramType] ) <> "After Hours" && MAX ( Center[CenterID] ) <> BLANK () && MAX ( Attendance[month-year] ) <> BLANK (), 1, 0 ) % = IF ( [CountOfAbsenses] / [CountOfAttendance] = BLANK (), "0%", [CountOfAbsenses] / [CountOfAttendance] )Best Regards
MaggieCommunity Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.