Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hi guys,
I've a very simple question, but I can't figure it out myself. I have a list with two columns with in the first one numbers with duplicate values and in the second column letters that belong to that number. I want to create a column for each of this letter.
Nr Letter
1 A
2 A
2 B
3 A
I want;
Nr Column1 Column2 ....
1 A
2 A B
3 A
How can I achieve this in Power BI? Or Excel, that would do the trick to.
Solved! Go to Solution.
Hi,
using this post of how to create a partition index, you can write this in the advanced editor of power query
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXJUitWJVjJCYTmBWcYQsVgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Nr = _t, Letter = _t]), Partition = Table.Group(Source, {"Nr"}, {{"Partition", each _, type table}}), AddedCustom = Table.AddColumn(Partition, "Custom", each Table.AddIndexColumn([Partition], "Index", 1,1)), RemovedColumns = Table.RemoveColumns(AddedCustom,{"Partition"}), ExpandedCustom = Table.ExpandTableColumn(RemovedColumns, "Custom", {"Letter", "Index"}, {"Letter", "Index"}), PivotedColumn = Table.Pivot(Table.TransformColumnTypes(ExpandedCustom, {{"Index", type text}}, "nb-NO"), List.Distinct(Table.TransformColumnTypes(ExpandedCustom, {{"Index", type text}}, "nb-NO")[Index]), "Index", "Letter") in PivotedColumn
cheers,
S
Hi,
using this post of how to create a partition index, you can write this in the advanced editor of power query
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUXJUitWJVjJCYTmBWcYQsVgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Nr = _t, Letter = _t]), Partition = Table.Group(Source, {"Nr"}, {{"Partition", each _, type table}}), AddedCustom = Table.AddColumn(Partition, "Custom", each Table.AddIndexColumn([Partition], "Index", 1,1)), RemovedColumns = Table.RemoveColumns(AddedCustom,{"Partition"}), ExpandedCustom = Table.ExpandTableColumn(RemovedColumns, "Custom", {"Letter", "Index"}, {"Letter", "Index"}), PivotedColumn = Table.Pivot(Table.TransformColumnTypes(ExpandedCustom, {{"Index", type text}}, "nb-NO"), List.Distinct(Table.TransformColumnTypes(ExpandedCustom, {{"Index", type text}}, "nb-NO")[Index]), "Index", "Letter") in PivotedColumn
cheers,
S
Great solution! Easy to use and works perfectly.
Much better than the Excel solutions.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
89 | |
88 | |
83 | |
64 | |
49 |
User | Count |
---|---|
125 | |
111 | |
88 | |
69 | |
66 |