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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
rpinxt
Solution Sage
Solution Sage

Lookup in Power Query Editor

I have 2 table which I cannot merge due to granularity:

This is the main:

rpinxt_0-1747054155858.png

 

And this is the other:

rpinxt_1-1747054179796.png

 

So wanted to merge them on country and then get category in the main table.

Looked liked it worked but then I noticed my lines got doubeld.

Most likely because the main table has Business and therefore the country is in for every business.

 

I could add business to the lookup table but then I would always be doing double maintenance if new countries were in scope.

 

Was thinking of not merging but just do a lookup from the main table into the lookup tabel and then get category from the lookup table in my custom column in the main table.

 

What would the M-code be for something (simple) like this?

 

1 ACCEPTED SOLUTION
rpinxt
Solution Sage
Solution Sage

Ok I was able to find a solution found in a power query video explaining this.
Would think it would be easier, not that it is hard but it looks more like a workaround.

= #"*V* Category"[Category]{List.PositionOf(#"*V* Category"[Country],[Country])}

 

Looking first up where the poistion is of the category

x = List.PositionOf(#"*V* Category"[Country],[Country])

and than use that to get the actual category...
- #"*V* Category"[Category]{ x }

 

Maybe there are better and easier solutions for when merge doesn't work but I will go with this for now 🙂

View solution in original post

1 REPLY 1
rpinxt
Solution Sage
Solution Sage

Ok I was able to find a solution found in a power query video explaining this.
Would think it would be easier, not that it is hard but it looks more like a workaround.

= #"*V* Category"[Category]{List.PositionOf(#"*V* Category"[Country],[Country])}

 

Looking first up where the poistion is of the category

x = List.PositionOf(#"*V* Category"[Country],[Country])

and than use that to get the actual category...
- #"*V* Category"[Category]{ x }

 

Maybe there are better and easier solutions for when merge doesn't work but I will go with this for now 🙂

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors