Power Query - Group By, Text Combine List Distinct & Concatenate Text
12:37 04 Nov 2021

I'm new to Power Query in Excel and want to apply a number of different functions to be able to achieve my target table, but I'm not sure on the syntax of how to bring this together..

I want to go from this...

enter image description here

to this..

enter image description here

I started by using the following steps;

  • Select input table range (entire blue dataset)
  • Select Transform
  • Select Group By -> pooled ID, and also Target
  • I then update the formula as per the screenshot and formula below but for one of the columns, the value returned is 'Error', as shown in the screenshot, and can't think why.. When I open the error it shows:

Expression.Error: The column 'single ID' of the table wasn't found. Details: single ID

enter image description here

Formula as text...

= Table.Group(#"Changed Type", {"pooled ID", "Target"}, {
     {"Targets Combined", each Text.Combine([Target], "; "), type text}, 
     {"Single IDs Combined", each Text.Combine([single ID], "; "), type text}, 
     {"single ID Count", each Table.RowCount(_), Int64.Type}}) 

I also want to introduce the final column and rename the headers as per the green example but I get an error when changing the headers.

Any advice would be most appreciated!

powerquery m