power query lookup table with duplicates

adamelston

New Member
Joined
Jul 22, 2016
Messages
31
Hello, I am trying to make a lookup table to link two tables but there are duplicates in both tables. I think what I need is to ensure unique rows and have any duplicate lookup values in columns. If my first table is as below:
IDRegion
xNorth
ySouth
xEast
zWest
xWest

I think I need to create a table like this:

IDRegion 1Region 2
xNorthEast
ySouth
zNorthWest

I've been messing around with pivots in power query but can't seem to create second table. Please could you let me know how best to do this?
Many thanks,
A
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
maybe

IDRegionIDRegion.1Region.2Region.3
xNorthxNorthEastWest
ySouthySouth
xEastzWest
zWest
xWest

with Power Query aka Get&Transform
Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table10"]}[Content],
    Grp = Table.Group(Source, {"ID"}, {{"Count", each _, type table}}),
    List = Table.AddColumn(Grp, "Region", each [Count][Region]),
    Extract = Table.TransformColumns(List, {"Region", each Text.Combine(List.Transform(_, Text.From), ","), type text}),
    Split = Table.SplitColumn(Extract, "Region", Splitter.SplitTextByAnyDelimiter({","}, QuoteStyle.Csv))
in
    Split
 
Last edited:
Upvote 0
Many thanks for quick response. That looks like it would do it but I am not sure how to use that code to achieve what I need. I am still at the point and click stage with power bi/dax. Do you know if there is a menu selection for this in power query?!
A
 
Upvote 0
update your profile about Excel version

Alt A PN O Q and in new window Alt H Q then replace code there with copied from the post
your source data should be an Excel Table (Ctrl T)
 
Upvote 0
update your profile about Excel version

Alt A PN O Q and in new window Alt H Q then replace code there with copied from the post
your source data should be an Excel Table (Ctrl T)

Thanks for your help. This works for my example data but not quite for my real data (with relevant table names/headings changed). I will keep trying but this was very useful.
 
Upvote 0
so post representative source data with original structure and generic values if necessary
 
Upvote 0

Forum statistics

Threads
1,223,774
Messages
6,174,456
Members
452,566
Latest member
Bonnie_bb

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top