Reputation: 400
I would like to create a table based on a visible one, in which there will be no duplicate values in column A and no duplicate values in the content of column B. What functions should pay attention to? I am asking for advice, I haven't found a function to remove duplicates + move to another table. The number of rows varies depending on the data source.
Upvotes: 0
Views: 266
Reputation: 2725
I assume your table is named Table1
, you can do it this way:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Table.Distinct = Table.Distinct(Source),
Text.Split = Table.TransformColumns(Table.Distinct, {"B", (x)=>Text.Split(x, ", ")}),
List.Distinct = Table.TransformColumns(Text.Split, {"B", List.Distinct}),
Text.Combine = Table.TransformColumns(List.Distinct, {"B", (x)=>Text.Combine(x,",")})
in
Text.Combine
If you like shorter version, then it can be as follow
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Table.Distinct = Table.Distinct(Source),
Text.Distinct = Table.TransformColumns(Table.Distinct, {"B", (x)=>Text.Combine(List.Distinct(Text.Split(x, ", ")),", ")})
in
Text.Distinct
Upvotes: 2
Reputation: 1634
Specifically for you case you my use this code:
= Table.Group(YourTable, "A", {"B", each Text.Combine(List.Sort(List.Distinct(Text.Split([B]{0}, ", "))), ", ")})
But following code is more robust (since, there may be different values in each row of Column B):
= Table.Group(YourTable, "A", {"B", each Text.Combine(List.Sort(List.Union(List.Transform([B], each List.Distinct(Text.Split(_, ", "))))), ", ")})
Upvotes: 2