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 have the following table
Name | ID1 | Item Type | ID2 | ID3 | USD Amount | ID4 | Rank | Contracts | Notes |
Bank1 | 8910 | ||||||||
Bank1 | 100 | SH782 | 400 | ||||||
Bank1 | 123 | Vendor | |||||||
Bank1 | 456 |
Utilizing DAX or Power Query, I need it to be transformed to the following
Name | ID1 | Item Type | ID2 | ID3 | USD Amount | ID4 | Rank | Contracts | Notes |
Bank1 | 123 | Vendor | 8910 | 456 | 100 | SH782 | 400 |
I utilized the SUMMARIZE function and pulled all of those datafields into it, but still get the rows being separated.
In Power Query I pasted your data into a table and achieved that result with this M code.
The first thing it does is transposes the table so your headers are now rows in column1. Then I replaced all the " " values with nulls and created a custom column to get the first non-null value (the ?? in the code below means to coalesce) This gets the first value from each of those columns and returns it as 1 column which I named Value.
Then I removed columns 2-5 and pivoted the header column (column1) with 'Value' as the values using the "Don't aggregate" under advanced options of the pivot column dialog box.
Hope this helps!
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8kvMTVXSUfJ0MQSRJam5CiGVBRARIzBpDCRDg10UHHPzS/NKwEImQDIoMS8bSDnn55UUJSaXFAPZfvklqcVKsTrRSk5ASZB5ClBsYWlogMRFxdg0wLChAUhfsIe5BcgxJgYGWHUZGoEcGZaal5JfhNMafFaZmJphVx8LAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t, #"(blank).3" = _t, #"(blank).4" = _t, #"(blank).5" = _t, #"(blank).6" = _t, #"(blank).7" = _t, #"(blank).8" = _t, #"(blank).9" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"(blank).1", type text}, {"(blank).2", type text}, {"(blank).3", type text}, {"(blank).4", type text}, {"(blank).5", type text}, {"(blank).6", type text}, {"(blank).7", type text}, {"(blank).8", type text}, {"(blank).9", type text}}),
#"Transposed Table" = Table.Transpose(#"Changed Type"),
#"Replaced Value" = Table.ReplaceValue(#"Transposed Table"," ",null,Replacer.ReplaceValue,{"Column2", "Column3", "Column4", "Column5"}),
#"Added Custom" = Table.AddColumn(#"Replaced Value", "Value", each [Column2] ?? [Column2] ?? [Column3] ?? [Column4] ??[Column5]),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Column2", "Column3", "Column4", "Column5"}),
#"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Column1]), "Column1", "Value")
in
#"Pivoted Column"
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.
User | Count |
---|---|
23 | |
10 | |
10 | |
9 | |
7 |