Forum Discussion
WalterM91
Jul 12, 2023Copper Contributor
Duplicate values in a column when another column has duplicated values
Hi, I would need your kind support on a matter regarding the Power Query Editor for an Excel file I am developing. I have a table as follows: ID | Letter | Value 001 | ...
- Jul 12, 2023
As variant
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], names = Table.ColumnNames( Source ), #"Changed Type" = Table.TransformColumnTypes( Source, { {"ID", type text}, {"Letter", type text}, {"Value", Int64.Type} }), #"Grouped Rows" = Table.Group( #"Changed Type", {"Letter"}, { {"Data", each [ tblOrder = Table.Sort(_,{{"ID", Order.Ascending}}), fillUp = Table.FillUp(tblOrder,{"ID"}), getRow = Table.FirstN( fillUp, 1 ) ][getRow] } }), keepData = Table.SelectColumns(#"Grouped Rows",{"Data"}), expandData = Table.ExpandTableColumn( keepData, "Data", names, names) in expandData
Please check attached.
SergeiBaklan
Jul 12, 2023Diamond Contributor
As variant
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
names = Table.ColumnNames( Source ),
#"Changed Type" = Table.TransformColumnTypes(
Source,
{
{"ID", type text},
{"Letter", type text},
{"Value", Int64.Type}
}),
#"Grouped Rows" = Table.Group(
#"Changed Type",
{"Letter"},
{
{"Data",
each [
tblOrder = Table.Sort(_,{{"ID", Order.Ascending}}),
fillUp = Table.FillUp(tblOrder,{"ID"}),
getRow = Table.FirstN( fillUp, 1 )
][getRow]
}
}),
keepData = Table.SelectColumns(#"Grouped Rows",{"Data"}),
expandData = Table.ExpandTableColumn(
keepData,
"Data",
names, names)
in
expandData
Please check attached.
- WalterM91Jul 13, 2023Copper ContributorHi Sergei, the solution works great, thanks.
- SergeiBaklanJul 13, 2023Diamond Contributor
WalterM91 , you are welcome, glad to help