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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Vlookup from two tables and match both results in powerbi

Hello, 

I want to match two column in both tables from data to key and return the cost column into the data table.

 

I have a key table

Type    Type 2        Cost

40         Half            80

40         Full           150

20         Full             40

20         Half            90

 

I have a data table

It lists similar to the key but doesnt have cost. I would like to match the two columns from the key table and return the cost in the data table. 

Type   Type 2

40        Half

20       Half

40      Full

etc      etc

 

Output : In Data Table 

Type   Type 2   Cost

40        Half       80

20       Half        40

40      Full        150

20      Full          90

 

I have a relationship between Key Table - Type ( Many to Many) to Data Table - Type. 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You could add a column onto the Data table like

Cost = LOOKUPVALUE( 'Key'[Cost], 'Key'[Type], 'Data'[Type], 'Key'[Type 2], 'Data'[Type 2])

View solution in original post

3 REPLIES 3
jdbuchanan71
Super User
Super User

@Anonymous 

You could create a new column that is 'Type' & 'Type 2' on both tables and join it like that.

jdbuchanan71_0-1655219194178.png

You would add the Type_Key filed to both tables and join the using that field.

Assuming the entries on your key table are unique based on Type & Type2 the join should be a *:1 and then you can use the RELATED function to pull the data.

 

johnt75
Super User
Super User

You could add a column onto the Data table like

Cost = LOOKUPVALUE( 'Key'[Cost], 'Key'[Type], 'Data'[Type], 'Key'[Type 2], 'Data'[Type 2])
Anonymous
Not applicable

Thanks very much, this worked perfectly! 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.