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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
bigrods
Helper III
Helper III

Filter Many to Many relationship by field

Hi,

 

I have an issue with trying to get my data together that I hope someone could help with and I can explain adequately!

 

I have 2 tables: Referrals and Caseload.

The Referrals table is a list of patients with a referral to 2 services across different sites - it has a "Referral Date" field that is any can be any date.  A patient could have a referral opened at multiple sites in the month. I would like to create a Page Filter for "Site" in the referrals table

 

The Caseload table is a list of patients on each caseload at the beginning of each month (as it's a snapshot) - it has a "Month" field that is set as the 1st of each month. Again, a patient could be on a caseload at multiple sites at the month.

 

For each month I need to see both the cumulative and opened referrals, so created a date table to help me do this. The date table is based on the referral table. I have created a measure in the referral table that gives me these no's accurately.

 

I have a filter on the page based on "Site" in the Referrals table and I then need to see the no's on the caseload at each month across each site and where referrals are cumulative or opened and if each caseload entry has a referral logged or not but the issue I'm having is that: 

 

I can't seem to limit the caseload no's by Site (in the Referrals table) - the relationship between Referral > Caseload is by Patient ID, so when I filter the page by Site, it gives me all the referrals for that site, but then the caseload no's include where Patient ID's appear at other sites too. The relationship is Many - Many as a Patient could register and re-register and have multiple referrals at multple sites and also be allocated onto a caseload multiple times.

 

I just need to limit the caseload no's by Site as well if possible? I have created a key called PatientSite on both tables joining the Patient ID and Site values but the no's are still the same.

 

This is what no's should be:

CaseloadPt CountReferral LoggedReferral Not Logged
Drug & Alcohol1224973
Throughcare1697

 

This is what I'm getting:

CaseloadPt CountReferral LoggedReferral Not Logged
Drug & Alcohol1265472
Throughcare241014

 

(the extra no's are where Pts are on caseloads at other sites - I just need to limit those where at the Referral > Site. The Many - Many relationship is stopping this I think.

 

The "Referral Logged" measure is as follows: 

 

Referral Logged = CALCULATE(COUNT('All Caseloads'[Patient id]),FILTER('All Caseloads','All Caseloads'[referral_ID_exists]="Yes"))
 

The "Referral Not Logged" measure is as follows:

Referral Not Logged = CALCULATE(COUNT('All Caseloads'[Patient ID]),FILTER('All Caseloads','All Caseloads'[referral_ID_exists]="No"))
 

I hope I've explained ok! It feels like I've rambled!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @bigrods 

Many-to-many relationships can cause a lot of problems, which is why it is also called a weak relationship. In most cases, it can be solved by creating a shared dimension and creating a one-to-many relationship from the shared dimension to the fact table. Avoid this type of relationship in your model. The current scenario is more suitable for sharing dimensions.

I found an article about one to many and many to many relationship between tables ,you can make some changes through this article .

https://radacad.com/many-to-one-or-many-to-many-the-cardinality-of-power-bi-relationship-demystified

 

Best Regards

Community Support Team _ Ailsa Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @bigrods 

Many-to-many relationships can cause a lot of problems, which is why it is also called a weak relationship. In most cases, it can be solved by creating a shared dimension and creating a one-to-many relationship from the shared dimension to the fact table. Avoid this type of relationship in your model. The current scenario is more suitable for sharing dimensions.

I found an article about one to many and many to many relationship between tables ,you can make some changes through this article .

https://radacad.com/many-to-one-or-many-to-many-the-cardinality-of-power-bi-relationship-demystified

 

Best Regards

Community Support Team _ Ailsa Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

PaulDBrown
Community Champion
Community Champion

I suggest you create dimension tables for the fields common to both tables and create one-to-many relationships. You can then use these dimension tables in your filters, slicers measures etc...

It is highly recommended to avoid many-to-many relationships since they can produce unexpected (and hard to detect) results.





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.