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
OleMcDonald
Helper I
Helper I

Count records in a joined table

I have two tables [Account] and [Contact]

They have a one (account) to many (contact) join 

The [Contact] table has a [Job Group] column

The [Job Group] is populated with a single value like "CEO" or "CFO" of "CIO"

 

I am trying to figure out how many [Account] records do not have a "CEO"

 

I tried using the Quick Measure to come up this this but it gives me a total count of accounts, not just accounts without  a CEO

Count of Id for CEO = 
CALCULATE(
	COUNTA('Account'[Id]),
	'Contact'[Job_Group__c] <> { "CEO" }

 

1 ACCEPTED SOLUTION
AlB
Super User
Super User

Hi @OleMcDonald 

 

Count of Id for CEO =
COUNTROWS (
    FILTER (
        'Account',
        CALCULATE ( COUNT ( 'Contact'[Job_Group__c] ), 'Contact'[Job_Group__c] = "CEO" ) = 0
    )
)

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

View solution in original post

2 REPLIES 2
edhans
Super User
Super User

See if this measure works. You shouldn't use COUNTA() here. The only thing it can do that COUNT cannnot is use boolean comparisons, but I don't think you need that. Just count the rows that meet your critera.

Counting Measure =
COUNTROWS(
    FILTER(
        TableName,
        TableName[Field] <> "CEO"
    )
)

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
AlB
Super User
Super User

Hi @OleMcDonald 

 

Count of Id for CEO =
COUNTROWS (
    FILTER (
        'Account',
        CALCULATE ( COUNT ( 'Contact'[Job_Group__c] ), 'Contact'[Job_Group__c] = "CEO" ) = 0
    )
)

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

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.