Forum Discussion

nimblecat's avatar
nimblecat
Frequent Visitor
3 years ago
Solved

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!!

  • Hi nimblecat.

     

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

     

     

2 Replies

  • talbot's avatar
    talbot
    Regular Visitor

    Hi nimblecat.

     

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

     

     

  • wdx223_Daniel's avatar
    wdx223_Daniel
    Community Champion

    =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 .