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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
khalilliraqui
Regular Visitor

Counting using related tables

I have three tables related to each others (two tables many-to-many) : lets take this as an example 

A person has many resources

power bi.png

I wanted to count for example : for every resource the number of people who has this resource, with a special condition on person for example firstname starts with "j".

I try many functions like filter or others but theese function only filter into the same table.

how can i use join on couting ?

 

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

Hi khalilliraqui,

 

According to your description, you want to get the count of resource owner persons which first name start with “j”?

 

If as I said, you can follow below steps):

 

  1.  Create sample table, ‘Person’, ’Personal Source’ , ‘Resource Type’.

‘Person’:

Capture.PNG

’Personal Source’:

 Capture2.PNG

‘Resource Type’:

 Capture3.PNG

  1. Write the Dax formula of requirement:

 

Recoure Count of Person Start with 'j' = DISTINCT( SELECTCOLUMNS('Personal Source',"Resource Type",RELATED('Resource Type'[Name]),"Count",COUNTX(FILTER('Personal Source','Personal Source'[Resource Type ID]=EARLIER('Personal Source'[Resource Type ID])&& LEFT(RELATED(Person[First Name]))="j"),'Personal Source'[Person ID])))

 

 Capture4.PNG

 

Reference:

LEFT Function (DAX)

RELATED Function (DAX)

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

1 REPLY 1
v-shex-msft
Community Support
Community Support

Hi khalilliraqui,

 

According to your description, you want to get the count of resource owner persons which first name start with “j”?

 

If as I said, you can follow below steps):

 

  1.  Create sample table, ‘Person’, ’Personal Source’ , ‘Resource Type’.

‘Person’:

Capture.PNG

’Personal Source’:

 Capture2.PNG

‘Resource Type’:

 Capture3.PNG

  1. Write the Dax formula of requirement:

 

Recoure Count of Person Start with 'j' = DISTINCT( SELECTCOLUMNS('Personal Source',"Resource Type",RELATED('Resource Type'[Name]),"Count",COUNTX(FILTER('Personal Source','Personal Source'[Resource Type ID]=EARLIER('Personal Source'[Resource Type ID])&& LEFT(RELATED(Person[First Name]))="j"),'Personal Source'[Person ID])))

 

 Capture4.PNG

 

Reference:

LEFT Function (DAX)

RELATED Function (DAX)

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Kudoed Authors