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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
NMahi1703
Frequent Visitor

Filtering Data in Another Table which has the relationship with One table with Mutiple Conditions

Hi Team,

I Have One table Name Table_1 below 

Account IDID
94841811
94843291
94844691

Another Table as Table_2

Account NumberBilliDName
94841811P1
94843291P2
9484NAP3
9484NAP4

I have the realtion between Table1 to Table2 with Account Id and Account Number.
My requirment is if Id  in table is maching with Billid in Table2 then that prodcut has to display.If There is no Match found then Need to display all the Name's in Table 
Output:

IDAccount NOName
18119484P1
32919484P3
46919484P1
46919484P2
46919484P3
46919484P4

Kindly Help Me. 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @NMahi1703,

You can create a new table with crossjoin function with table 1 field and table 2 Name fields, then add a filter to remove not match records based on the raw table records mapping.

Expand = 
VAR idList =
    CALCULATETABLE (
        VALUES ( Table2[BilliD] ),
        FILTER ( Table2, [BilliD] <> "NA" )
    )
VAR mapping =
    SELECTCOLUMNS (
        FILTER ( Table2, [BilliD] <> "NA" ),
        "Merged",
            [Account Number] & "-" & [BilliD] & "-" & [Name]
    )
RETURN
    FILTER (
        CROSSJOIN ( Table1, VALUES ( Table2[Name] ) ),
        IF (
            [ID] IN idList,
            [Account ID] & "-" & [ID] & "-" & [Name] IN mapping,
            TRUE ()
        )
    )

1.PNG
Regards,

Xiaoxin Sheng

View solution in original post

2 REPLIES 2
NMahi1703
Frequent Visitor

Hi @Anonymous ,

 

Thanks for you help , small change in the condition and data could you please help me out with below senario.
Table1

Account IDID
36301811
76253291
76255567

Table2

Account NumberBilliDName
3630NAP1
3630NAP2
3630NAP3
3630NAP4
76253291P5
76253291P6
88883291P7
76254691P8
7625 P9
7625 P10
7625 P11

Now here as mentioned above account id and Account Number has an many to many relationship.Desiried output is 

IDName
1811P1
1811P2
1811P3
1811P4
3291P5
3291P6
5567P5
5567P6
5567P8
5567P9
5567P10
5567P11
Anonymous
Not applicable

HI @NMahi1703,

You can create a new table with crossjoin function with table 1 field and table 2 Name fields, then add a filter to remove not match records based on the raw table records mapping.

Expand = 
VAR idList =
    CALCULATETABLE (
        VALUES ( Table2[BilliD] ),
        FILTER ( Table2, [BilliD] <> "NA" )
    )
VAR mapping =
    SELECTCOLUMNS (
        FILTER ( Table2, [BilliD] <> "NA" ),
        "Merged",
            [Account Number] & "-" & [BilliD] & "-" & [Name]
    )
RETURN
    FILTER (
        CROSSJOIN ( Table1, VALUES ( Table2[Name] ) ),
        IF (
            [ID] IN idList,
            [Account ID] & "-" & [ID] & "-" & [Name] IN mapping,
            TRUE ()
        )
    )

1.PNG
Regards,

Xiaoxin Sheng

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 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.