I am struggling to add a filter to this DAX CALCULATETABLE/SUMMARIZE code in POWER BI. Unfortunately, I get the following error:
Function SUMMARIZE expects a column name as argument number 6
I have tried different filters with no luck as I keep getting the same error.
StudentAbsenceXXXX = CALCULATETABLE (
SUMMARIZE (
'Attendance2425',
'Attendance2425'[AdmissionNo],
'Students'[Year Group(s)],
"Student Sessions Present",
CALCULATE (COUNTROWS ( 'Attendance2425' ),'Attendance2425'[Mark Meaning] = "Present" || 'Attendance2425'[Mark Meaning] = "Educational Activity"),
FILTER(
'Attendance2425',
'Attendance2425'[Mark Meaning] = "Educational Activity"
)
))
Ideally I would like to apply a filter from a related table 'Students' using the field 'Students'[Year Group(s)] but tried something simpler to try and correct the first error.
Try to use a variable for your measure :
StudentAbsenceXXXX =
VAR SessionsPresent =
CALCULATE(
COUNTROWS('Attendance2425'),
'Attendance2425'[Mark Meaning] = "Present" ||
'Attendance2425'[Mark Meaning] = "Educational Activity"
)
RETURN
CALCULATETABLE(
SUMMARIZE(
'Attendance2425',
'Attendance2425'[AdmissionNo],
'Students'[Year Group(s)],
"Student Sessions Present", SessionsPresent
),
FILTER(
'Attendance2425',
'Attendance2425'[Mark Meaning] = "Educational Activity"
)
)