Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I don't know if that title accurately describes what I'm looking for, but here it goes.
I have a table with two columns. The first column is a unique key - let's say a part #. The second column is an attribute. Some keys have 1 attribute, some keys have multiple attributes. What I need to do is put each attribute in a column next to the key so that each key only takes up a single row. For instance, I need this:
Key | Attribute |
PartABC | Blue |
PartXYZ | Red |
PartXYZ | Round |
PartXYZ | Slim |
Part123 | Black |
Part123 | Square |
To convert to:
Key | Attribute.1 | Attribute.2 | Attribute.3 |
PartABC | Blue | ||
PartXYZ | Red | Round | Slim |
Part123 | Black | Square |
Any help to this end is greatly appreciated!
Solved! Go to Solution.
@bvbull200 , you can first group by key column and then extract attributes,
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkgsKnF0clbSUXLKKU1VitWBCEVERgGFglJT0EXyS/PQxYJzMnPhQoZGxmCzEpOz0cSCC0sTi4A2xAIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Key = _t, Attribute = _t]),
#"Grouped Rows" = Table.Group(
Source,
{"Key"},
{{"Attr", each Table.Transpose(Table.SelectColumns(_,{"Attribute"}))}}
),
#"Expanded Attr" = Table.ExpandTableColumn(#"Grouped Rows", "Attr", {"Column1", "Column2", "Column3"}, {"Attr.Column1", "Attr.Column2", "Attr.Column3"})
in
#"Expanded Attr"
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
@bvbull200 , you can first group by key column and then extract attributes,
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkgsKnF0clbSUXLKKU1VitWBCEVERgGFglJT0EXyS/PQxYJzMnPhQoZGxmCzEpOz0cSCC0sTi4A2xAIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Key = _t, Attribute = _t]),
#"Grouped Rows" = Table.Group(
Source,
{"Key"},
{{"Attr", each Table.Transpose(Table.SelectColumns(_,{"Attribute"}))}}
),
#"Expanded Attr" = Table.ExpandTableColumn(#"Grouped Rows", "Attr", {"Column1", "Column2", "Column3"}, {"Attr.Column1", "Attr.Column2", "Attr.Column3"})
in
#"Expanded Attr"
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.