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
RYU209
Helper III
Helper III

Check if a value exists between many-to-tables in Direct Query

Hello,

I have two Direct Query tables with a Many-To-Many relationship (Table1 and Table2). They are connected by a key that is made up of a concatenated Transaction # and Order #. 

I have a Table Visual that holds records of Transaction, Order, and some other data elements from Table2. How can I create a measure filter that filters this visual to only show records that have a concatenated key that also exists in Table1? 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You could create a measure like

Value is in Table1 =
VAR CurrentKey =
    SELECTEDVALUE ( 'Table2'[concatenated key] )
RETURN
    IF ( CurrentKey IN ALL ( 'Table1'[concatenated key] ), 1 )

and then use that as a visual level filter to only show when the value is 1

View solution in original post

4 REPLIES 4
johnt75
Super User
Super User

You could create a measure like

Value is in Table1 =
VAR CurrentKey =
    SELECTEDVALUE ( 'Table2'[concatenated key] )
RETURN
    IF ( CurrentKey IN ALL ( 'Table1'[concatenated key] ), 1 )

and then use that as a visual level filter to only show when the value is 1

@johnt75 That worked perfectly! 

Could you explain what IN and ALL are doing so I can understand how it works? 

ALL returns all the values of Table 1 key regardless of any filters which may be applied, including any filters from the many-to-many relationship.

IN then checks to see whether the current key exists in those values.

@johnt75 Thank you!

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.

Top Solution Authors