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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Fetch the values from another table by matching column x with eith column A or B in the other table

Hello 

I need the values from table 1 by matching column x in table 1 with either column a or column b in table 2.
I tried to establish two relationships with table 1 to table 2 but I can only make one relationship active 

I have a column in table 1 that either matches column a in table 2 or column b in table 2.
Is there any better way to bring in all the values matching column a or column b

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

That would be someting like this.

Values = 
CALCULATE (
    SUM ( 'Table 2'[Values] ),
    FILTER (
        ALL ( 'Table 2'[ENPNSC_] ),
        'Table 2'[ENPNSC_] = 'Table 1'[Enpnsc_Calculated]
    )
) + 
CALCULATE (
    SUM ( 'Table 2'[Values] ),
    FILTER (
        ALL ( 'Table 2'[ENPNSC_] ),
        'Table 2'[ENPNSC_] = 'Table 1'[Pcsc_calcualted]
    )
)

jdbuchanan71_0-1659013973554.png

 

 

View solution in original post

6 REPLIES 6
jdbuchanan71
Super User
Super User

That would be someting like this.

Values = 
CALCULATE (
    SUM ( 'Table 2'[Values] ),
    FILTER (
        ALL ( 'Table 2'[ENPNSC_] ),
        'Table 2'[ENPNSC_] = 'Table 1'[Enpnsc_Calculated]
    )
) + 
CALCULATE (
    SUM ( 'Table 2'[Values] ),
    FILTER (
        ALL ( 'Table 2'[ENPNSC_] ),
        'Table 2'[ENPNSC_] = 'Table 1'[Pcsc_calcualted]
    )
)

jdbuchanan71_0-1659013973554.png

 

 

Thank you @jdbuchanan71 ,
It worked, I really appreciate it 😊

jdbuchanan71
Super User
Super User

Try it like this instead.

Value =
VAR _search = 'Table 1'[column x]
RETURN
    COALESCE (
        CALCULATE (
            FIRSTNONBLANK ( 'Table 2'[value], 1 ),
            FILTER ( ALL ( 'Table 2'[column a] ), 'Table 2'[column a] = _search )
        ),
        CALCULATE (
            FIRSTNONBLANK ( 'Table 2'[value], 1 ),
            FILTER ( ALL ( 'Table 2'[column b] ), 'Table 2'[column b] = _search )
        )
    )

jdbuchanan71_0-1658953286043.png

 

Hello @jdbuchanan71 

I'm sorry to revert again,
That is just picking first value in the column, i would like to pick every value 
For instance : 

bhavana097_0-1658999231903.png

Table 1 should be able to pick all the values in table 2 via matching either enpnsc_calculated field & ecpc_calculated field with table 2 [ ENPNSC_ ] field


Thank you very much in advance 

bhavana097
Frequent Visitor

Hello @jdbuchanan71 

Thank you for the solution, But i got an error back saying "mutliple values was supplied where single values are being expected".

bhavana097_0-1658947282678.png


Im sorry, i Forgot to mention that for one value in column a (enpnsc) & column b(pcsc) from table1 has the mutiple value in column x( enpnsc) table 2 
Targeted value is agency cost 

bhavana097_1-1658947814825.png

Im looking forward to discussing with you  



jdbuchanan71
Super User
Super User

@Anonymous 

You can add a column to table 1 like this.

 

Value = 
COALESCE(
    LOOKUPVALUE('table 2'[value],'table 2'[column a],'table 1'[column x]),
    LOOKUPVALUE('table 2'[value],'table 2'[column b],'table 1'[column x])
)

jdbuchanan71_1-1658937255611.png

 

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.