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
Anonymous
Not applicable

Filtering with many-to-many relationship

Hi!

 

For the last three days I am trying to do some filtering on many to many related tables. Unfortunately I have not found a solution yet on this forum.  I have thee related tables

 

Table A > Excel import
Table B > DirectQuery SQL 

Table C > DirecyQuery SQL

 

Those three tables are related with an order_id field. PowerBI automatically recognizes the relation as 'many to many' , cross filter direction 'both' with security check box enabled. 

 

What I try to accomplish is that I want to show the records of table B which do no occur in table A. 

 

Methods I tryed which did not work:

- Merge queries with different join types.

- Calculated column.

- Enable 'Show items with no data'.

 

Whats is the correct way to achieve what I try to accomplish?

 

Thanks, Mark

1 ACCEPTED SOLUTION

You should be able to do this with your existing tables with a measure like the following:

 

In Table1 missing in Table2 = 
IF( HASONEVALUE(Table1[OrderID]), 
  Var _table1OrderID = MAX(Table1[OrderID])
  Var _table2RowsWithTable1ID = CALCULATETABLE(Table2, TREATAS({_table1OrderID},Table2[OrderID]))
  Var _countOfMIssingRows = COUNTROWS(_table2RowsWithTable1ID)
  return IF(_countOfMissingRows = 0,"Missing")
)

 

Returns a result like this

2019-03 missing in other table.png

View solution in original post

11 REPLIES 11

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.