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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
nimblecat
Frequent Visitor

Power Query M: IF with VLOOKUP

I need a Power Query M formula version for creating a "column D" that does a VLOOKUP from TableB on colA but if it doesn't exist, then just pull col C from the original TableA.

 

TableA and TableB has a many:one relationship set-up.

In excel formula this would be:

 

 

col D = IF(VLOOKUP(... ), COLUMN_IN_TABLE_A, VLOOKUP(... )

 

 

TableA: 

col Acol Bcol C
A1apple
A23banana
B3cherry
C4daisy

 

TableB:

col Acol B
Add
Bcc

 

Wanted Final Result:

col Acol Bcol Ccol D
A1appledd
A23bananadd
B3cherrycc
C4daisydaisy

 

THANKS!!

1 ACCEPTED SOLUTION
talbot
Regular Visitor

Hi nimblecat.

 

Is this the kind of thing you're looking for?

 

talbot_0-1664301560750.png

 

View solution in original post

2 REPLIES 2
wdx223_Daniel
Super User
Super User

=Table.AddColumn(TableA,"col D",each TableB{[#"col A"=[col A]]}?[col B]? ??[col C])

 

the values must be unique in col A of TableB .

talbot
Regular Visitor

Hi nimblecat.

 

Is this the kind of thing you're looking for?

 

talbot_0-1664301560750.png

 

Helpful resources

Announcements
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 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors