Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
SamOvermars
Helper I
Helper I

How can I get a count that involves two tables?

Hello,

I cant find a way to get this to work but it sounds simple.
I have the following tables.

AttendedTable

SamOvermars_0-1665096176455.png

 

 

AbsentTable

SamOvermars_1-1665096214202.png

 

 


AllUsersTable - Which contains the users and the sections they belong to

SamOvermars_2-1665096265640.png

 

 

I have a one-to-one relationship between AbsentTable and AttendedTable using the SectionKey

I want to populate the absent column in the absent table by counting how many users (UserID) minus the number of attended people (Attendee) for each section. This should give me the number of absents from each section. I tried to use count (UserID), but it gave me the overall count in that table. Which is not what I need.
How Can I do that?

1 ACCEPTED SOLUTION
hnguy71
Memorable Member
Memorable Member

@SamOvermars ,

 

Try this:

VAR _UserSection = CALCULATE(COUNTROWS(AllUsers), FILTER(AllUsers, AllUsers[UserSection] = [Section]))
VAR _UserAttended = CALCULATE(SUM(Attended[Attendee]), FILTER(Attended, Absent[SectionKey] = Attended[SectionKey]))

RETURN

_UserSection - _UserAttended


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

1 REPLY 1
hnguy71
Memorable Member
Memorable Member

@SamOvermars ,

 

Try this:

VAR _UserSection = CALCULATE(COUNTROWS(AllUsers), FILTER(AllUsers, AllUsers[UserSection] = [Section]))
VAR _UserAttended = CALCULATE(SUM(Attended[Attendee]), FILTER(Attended, Absent[SectionKey] = Attended[SectionKey]))

RETURN

_UserSection - _UserAttended


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.