Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by watching the DP-600 session on-demand now through April 28th.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
I have two tables that look a little like this;
'Courses'
[Course_ID]
A
B
C
D
E
'Course Assignments'
[Course_ID]
A
C
D
B
B
E
A
I'm trying to calculate the number of assignments for each course in the 'Course' table so that I'd get
[Course_ID] [Assignment_Count]
A 2
B 2
C 1
D 1
E 1
My DAX for this won't work. It reads;
Assignment_Count =
COUNTA('Course Assignments'[ASSIGNMENT_ID]),FILTER('Course Assignments'[COURSE_ID]='Courses'[COURSE_ID])
Can anyone see what I'm doing wrong?
Thank you in advance.
Daniel.
Solved! Go to Solution.
You can create proper relationship between those two tables, then no measure is needed.
Alternatively, if no relationship, a measure as below works as well.
Assignment_Count =
CALCULATE (
COUNTA ( 'Course Assignments'[ASSIGNMENT_ID] ),
FILTER (
'Course Assignments',
'Course Assignments'[ASSIGNMENT_ID] = LASTNONBLANK ( Courses[Course_ID], "" )
)
)
See the attached pbix file.
You can create proper relationship between those two tables, then no measure is needed.
Alternatively, if no relationship, a measure as below works as well.
Assignment_Count =
CALCULATE (
COUNTA ( 'Course Assignments'[ASSIGNMENT_ID] ),
FILTER (
'Course Assignments',
'Course Assignments'[ASSIGNMENT_ID] = LASTNONBLANK ( Courses[Course_ID], "" )
)
)
See the attached pbix file.
Thank you, that's just what I need.
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
| User | Count |
|---|---|
| 45 | |
| 38 | |
| 34 | |
| 21 | |
| 17 |
| User | Count |
|---|---|
| 66 | |
| 65 | |
| 31 | |
| 26 | |
| 26 |