Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
If unpivot is even the correct term...
You can see, the vendorID is listed 6 times, one for each PaymentTypeID and its status (IsAllowed).
Can Power Query switch this so each VendorID is listed once, with 6 columns for each PaymentTypeID, and the values being the IsAllowed? For example, mave Power Query transform things to look something like this.
Solved! Go to Solution.
See if this works, paste into Advanced Editor in a blank query
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSAWM3R59gV6VYHYiIMRCHBIUiBEwwlJhiiJihiBhhGGyEbrARqsGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [VendorID = _t, PaymentTypeID = _t, IsAllowed = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"VendorID", Int64.Type}, {"PaymentTypeID", Int64.Type}, {"IsAllowed", type logical}}), #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Changed Type", {{"PaymentTypeID", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Changed Type", {{"PaymentTypeID", type text}}, "en-US")[PaymentTypeID]), "PaymentTypeID", "IsAllowed", List.Max) in #"Pivoted Column"
If not, @ImkeF
See if this works, paste into Advanced Editor in a blank query
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSAWM3R59gV6VYHYiIMRCHBIUiBEwwlJhiiJihiBhhGGyEbrARqsGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [VendorID = _t, PaymentTypeID = _t, IsAllowed = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"VendorID", Int64.Type}, {"PaymentTypeID", Int64.Type}, {"IsAllowed", type logical}}), #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Changed Type", {{"PaymentTypeID", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Changed Type", {{"PaymentTypeID", type text}}, "en-US")[PaymentTypeID]), "PaymentTypeID", "IsAllowed", List.Max) in #"Pivoted Column"
If not, @ImkeF
That showed me enough to get it - thanks! I don't want to post the code from the Advanced editor, but the setting I needed was this:
Unfortunately it's extremely slow...but that may just be a limit of power query when the source table is almost 20m rows.
Hmm, makes me think about something. A while ago I solved an slow Power Query unpivot issue using DAX.
https://community.powerbi.com/t5/Quick-Measures-Gallery/DAX-Unpivot/m-p/574832
Wonder if I could do something similar for a DAX Pivot... Hmm, I'll let you know if I figure that one out.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
100 | |
80 | |
63 | |
58 |
User | Count |
---|---|
148 | |
111 | |
94 | |
84 | |
67 |