Forum Discussion
Anonymous
7 years agoNot applicable
Get data & calculate values in rows without applying UnPivot command
Hi PBI Experts, I have a large & complex data set which is cumbersome to UnPivot. Why no UnPivot - I tried splitting the table to unpivot, then Unpivot them and later join them all, however, not ge...
Mariusz
Community Champion
7 years agoHi Anonymous
Please see the below M code that returns your desired result, you can copy it all and paste it in the newly created Blank Query's Advanced Editor.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WciwoyElV8MxLVtJRygzIyM9LBTIMDUAAyDA20DMwUAUyYLQhBsMIxjBGSAGpWJ1oJd/M5KL84vy0EqCgf1paZnKqsZkpWAu68UYwM9DNgjNMUQyPBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Customer = _t, Product = _t, #"Commission value" = _t, Americas = _t, Africa = _t, Middle_East = _t, India = _t, APAC = _t, Europe = _t, #"Total%" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Customer", type text}, {"Product", type text}, {"Commission value", Int64.Type}, {"Americas", Percentage.Type}, {"Africa", Percentage.Type}, {"Middle_East", Percentage.Type}, {"India", Percentage.Type}, {"APAC", Percentage.Type}, {"Europe", Percentage.Type}, {"Total%", Percentage.Type}}),
#"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Customer", "Product", "Commission value", "Total%"}, "Attribute", "Value"),
#"Added Custom" = Table.AddColumn(#"Unpivoted Columns", "Custom", each [Value] * [Commission value]),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", Int64.Type}})
in
#"Changed Type1"Let me know if it worked for you.
Best Regards,
Mariusz
If this post helps, then please consider Accepting it as the solution.
Please feel free to connect with me.

Mariusz
If this post helps, then please consider Accepting it as the solution.
Please feel free to connect with me.
Anonymous
7 years agoNot applicable
Hi Mariusz
Can you please also upload the PBIX file with your MCode for me to understand better ?
I am not a PBI expert :-)
Thanks,
Chandan.
- Mariusz7 years ago
Community Champion
Hi Anonymous
No problem see the below.
https://drive.google.com/fi0le/d/1aPwdy0pWpnE0JbK_UzR_Jokju03iGkmO/view?usp=sharing
let me know if you need anything else.