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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Frank_W
Frequent Visitor

Filter a table visual if it contains values from a filter which is based on an unrelated table

Hello friends,

I have 2 tables

Tables1

CustomerProduct
AOranges, Apple, Banana, Melon
BApple
C

Banana

D

Peach, Banana

E

Peach, Melon

 

Tables2

Product_Type
Apple
Peach
Banana
Melon
Orange


I want to create a filter Based on "Table2" , I then want Table1 visual to change based on the filter choices of Table2

ie if the user select "Apple" and "Melon" in the filter then Table2 visual will show Customers A,B and E

hope this explains things

thankyou

Frank

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @Frank_W,

You can try to use the following measure formula to compare between two table field values and return flag, then you can use it on visual level filter to filter records:

formula =
VAR productList =
    CALCULATE (
        CONCATENATEX ( VALUES ( Table1[Product] ), [Product], "," ),
        ALLSELECTED ( Table1 ),
        VALUES ( Table1[Customer] )
    )
VAR result =
    COUNTROWS (
        FILTER (
            ALLSELECTED ( Table2 ),
            SEARCH ( Table2[Product_Type], productList, 1, -1 ) > 0
        )
    )
RETURN
    IF ( result > 0, "Y", "N" )

Regards,

Xiaoxin Sheng

View solution in original post

6 REPLIES 6
AlanP514
Post Patron
Post Patron

Hai @Frank_W 

Testing =

VAR SelectedProduct = SELECTEDVALUE(Tables2[Product_Type])
RETURN
CONCATENATEX(
FILTER(
Tables1,
CONTAINSSTRING(Tables1[Product], SelectedProduct)
),
Tables1[Customer],
", "
)
try this code

 

Hello Alan P514,

thankyou very much for your code above, it works but the only issue I have is that when I place the data in a a table visual all of the data is in one row instead of one row per customer name

I appologies as It was my fault, as I should have said 
output = 

Customer
A
B
E

Please Share your PBIX file with me

Anonymous
Not applicable

HI @Frank_W,

You can try to use the following measure formula to compare between two table field values and return flag, then you can use it on visual level filter to filter records:

formula =
VAR productList =
    CALCULATE (
        CONCATENATEX ( VALUES ( Table1[Product] ), [Product], "," ),
        ALLSELECTED ( Table1 ),
        VALUES ( Table1[Customer] )
    )
VAR result =
    COUNTROWS (
        FILTER (
            ALLSELECTED ( Table2 ),
            SEARCH ( Table2[Product_Type], productList, 1, -1 ) > 0
        )
    )
RETURN
    IF ( result > 0, "Y", "N" )

Regards,

Xiaoxin Sheng

vicky_
Super User
Super User

You can use this guide on setting up an XOR filter based on your selections: https://apexinsights.net/blog/or-xor-slicing

and then you can use CONTAINSSTRING() as part of your filter conditions.

 

Honestly, I would recommend that you go back to PowerQuery / your data source and change the data structure so that you don't have to use CONTAINSSTRING(), and can just match the entire cell contents.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors