Power Query - Merge Creating Multiple Rows Where 2 Records Exist

karmaimages

Board Regular
Joined
Oct 1, 2009
Messages
112
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'm using power query to looking some values against an external data source of user accounts.

So where I have for example

NameManager
Joe Bloggs(Lookup Value)

If the user has 2 or more accounts as they're been recreated for example

Display NameAccount NameManager
Joe BloggsJoe BloggsJane Doe
Joe BloggsJoe Bloggs2Jane Doe
Joe BloggsJoe Bloggs3Jane Doe

Where I'm linking on Name and Display Name to gather the manager name I'm getting the result as

NameManager
Joe BloggsJane Doe
Joe Bloggs
Joe Bloggs

This is messing up some counts that are needed for reports as it's creating necessary rows, how do I get Power Query to only add the one row not create multiple for the same person?
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
I'm not quite understanding what you are looking for as a final result, but I think you are wanting to see just 1 Joe Bloggs with 1 Jane Doe. So in order to do that, you would do a Group By with your Display Name and Manager as the Groupings, and then a Count of Rows as an Aggregation, which for this example, I have named as "Count of Accounts"

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Display Name", type text}, {"Account Name", type text}, {"Manager", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Display Name", "Manager"}, {{"Count of Accounts", each Table.RowCount(_), Int64.Type}})
in
    #"Grouped Rows"
 
Upvote 0
After merging add a custom column and add something like
Power Query:
extData_[manager]
that should return the manager field from the first record of the merged external data table.
Mind M is case sensitive.
 
Upvote 0

Forum statistics

Threads
1,223,657
Messages
6,173,620
Members
452,525
Latest member
DPOLKADOT

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