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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Aayushi
Frequent Visitor

How to apply VLOOKUP in Power Query editor?

I need to check if a value of one column exists in another column of the same table.

I need to apply VLOOKUP in Power Query. 

With DAX, its possible but with Power Query, I am not able to find a proper solution.

Can someone please help me out?

1 ACCEPTED SOLUTION
v-tangjie-msft
Community Support
Community Support

Hi @Aayushi ,

 

In Power Query functions can be created like this:

(lookupValue as any, lookupTable as table, lookupColumnName as text, returnColumnValue as text) =>
let
// lookupTable= Products,
// lookupColumnName = "ProductKey",
// returnColumnValue = "Price",
// lookupValue = 1,
 colLookup = Table.Column(lookupTable, lookupColumnName),
 colToReturn = Table.Column(lookupTable, returnColumnValue),
 lookup = List.PositionOf(colLookup, lookupValue, 0),
 Result = if lookup >=0 then colToReturn{lookup} else "Not found"
in
 Result

Or

 

You can duplicate your query and merge the two queries to get the desired columns.

Disable the load from the duplicate one to avoid performance issues.

 

Please refer to the following documents for more information.

#PowerQuery – Replicate doing an Excel VLOOKUP in M – Erik Svensen

How to do a real VLOOKUP (false) in Power Query or Power BI – The BIccountant

VLOOKUP / XLOOKUP in Power Query - Bing video

VLOOKUP in Power Query Using List Functions - Bing video

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

 

View solution in original post

2 REPLIES 2
v-tangjie-msft
Community Support
Community Support

Hi @Aayushi ,

 

In Power Query functions can be created like this:

(lookupValue as any, lookupTable as table, lookupColumnName as text, returnColumnValue as text) =>
let
// lookupTable= Products,
// lookupColumnName = "ProductKey",
// returnColumnValue = "Price",
// lookupValue = 1,
 colLookup = Table.Column(lookupTable, lookupColumnName),
 colToReturn = Table.Column(lookupTable, returnColumnValue),
 lookup = List.PositionOf(colLookup, lookupValue, 0),
 Result = if lookup >=0 then colToReturn{lookup} else "Not found"
in
 Result

Or

 

You can duplicate your query and merge the two queries to get the desired columns.

Disable the load from the duplicate one to avoid performance issues.

 

Please refer to the following documents for more information.

#PowerQuery – Replicate doing an Excel VLOOKUP in M – Erik Svensen

How to do a real VLOOKUP (false) in Power Query or Power BI – The BIccountant

VLOOKUP / XLOOKUP in Power Query - Bing video

VLOOKUP in Power Query Using List Functions - Bing video

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.