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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

DISTINCTCOUNT with 2 different tables?

I can seem to make work      DISTINCTCOUNT ( Employee[Dept] ).

 

 

I have 2 tables:

 

AD table:

AD group

Employee

ITPJohn
ADMIRTim
ADMIRMary
ADMIRJohana
TJJAria
TJJArmeena
TJJJuana

 

 

 

 

Employee table:

 

Employee

Dept

JohnMarketing
TimMarketing
MaryMarketing
JohanaHR
AriaHR
ArmeenaHR
JuanaHR

 

(The tabled are connected through column Employee)

 

It is a 1 to many relationship.

 

I just want to count distinct dept on each AD group.

 

That is:

 

ITP      1

ADMIR     2

TJJ    1

 

I have used  DISTINCTCOUNT ( Employee[Dept] ) and then I drag AD group to the table and it doesnt work.

 

How can I make DISTINCTCOUNT work when using 2 tables?

1 ACCEPTED SOLUTION
DimaMD
Solution Sage
Solution Sage

Hi @Anonymous If your tables are not connected, then you can use this measure

CALCULATE( 
    DISTINCTCOUNT ( 'Employee table'[Dept] ), 
     TREATAS( VALUES('AD table'[Employee]),'Employee table'[Employee])
)

Screenshot_1.jpg


__________________________________________

Thank you for your like and decision

__________________________________________

Greetings from Ukraine

To help me grow PayPal: embirddima@gmail.com

View solution in original post

5 REPLIES 5
DimaMD
Solution Sage
Solution Sage

Hi @Anonymous If your tables are not connected, then you can use this measure

CALCULATE( 
    DISTINCTCOUNT ( 'Employee table'[Dept] ), 
     TREATAS( VALUES('AD table'[Employee]),'Employee table'[Employee])
)

Screenshot_1.jpg


__________________________________________

Thank you for your like and decision

__________________________________________

Greetings from Ukraine

To help me grow PayPal: embirddima@gmail.com
Greg_Deckler
Community Champion
Community Champion

@Anonymous Try:

Measure = COUNTROWS(DISTINCT('Employee'[Dept]))


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler  does not seem to work, I get value 2   for all. It seems that because the column is from another table the distinctcoutn does not work.

@Anonymous Try the attached PBIX below sig. 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Anonymous Is this a measure or a calculated column? If calculated column you will need to use RELATED.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.