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
Back2Basics
Helper IV
Helper IV

count between tables

I have a data set where I have two tables, sites and clients. Each client can have several sites and each site can have several different contacts (on the sites table)

 

What I am trying to do is to make a list where I have a column for client, a column for site and a column for contact. I can do this bit... but what I'm struggling with is being able to then place a colum which counts the number of sites for the client and the number of contacts for the site, and for the client.

 

Example:

Client    -  Site      -  Contact     -  Count sites  - Count contacts for site - Count contact for client

Client A - Site A1 - Contact A1 - 2                  -  2                                   -   3 

Client A - Site A1 - Contact A2 - 2                  -  2                                   -   3

Client A - Site A2 - Contact A3 - 2                  -  1                                   -   3

Client B - Site B1 - Contact B1 -  2                  - 1                                    - 2

Client B - Site B2 - Contact B2 - 2                   - 1                                    -  2

1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

Hi Back2Basics,

 

To achieve your requirement, create three calculate columns using DAX formula like this:

Count Sites = CALCULATE(DISTINCTCOUNT(Table1[Site]), FILTER(Table1, Table1[Client] = EARLIER(Table1[Client])))

Count contacts for site = CALCULATE(DISTINCTCOUNT(Table1[Contact]), FILTER(Table1, Table1[Site] = EARLIER(Table1[Site])))

Count contact for client = CALCULATE(DISTINCTCOUNT(Table1[Contact]), FILTER(Table1, Table1[Client] = EARLIER(Table1[Client])))

The result is as below and you can refer to PBIX file here: https://www.dropbox.com/s/a9l74rbc99abw7m/count%20between%20tables.pbix?dl=0捕获.PNG 

 

Regards,

Jimmy Tao

View solution in original post

1 REPLY 1
v-yuta-msft
Community Support
Community Support

Hi Back2Basics,

 

To achieve your requirement, create three calculate columns using DAX formula like this:

Count Sites = CALCULATE(DISTINCTCOUNT(Table1[Site]), FILTER(Table1, Table1[Client] = EARLIER(Table1[Client])))

Count contacts for site = CALCULATE(DISTINCTCOUNT(Table1[Contact]), FILTER(Table1, Table1[Site] = EARLIER(Table1[Site])))

Count contact for client = CALCULATE(DISTINCTCOUNT(Table1[Contact]), FILTER(Table1, Table1[Client] = EARLIER(Table1[Client])))

The result is as below and you can refer to PBIX file here: https://www.dropbox.com/s/a9l74rbc99abw7m/count%20between%20tables.pbix?dl=0捕获.PNG 

 

Regards,

Jimmy Tao

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.