Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
andya_utah
New Member

Complex Pivoting

I am trying to replicate results from an another ETL platform I utilize to arrive at a more complex piviot the BI seems to offer. I am new using BI.

 

I would like to go from a to b - if it is possible.. Any pointers would be appreciated...

 

A

ClassNameBeginYearAssessmentTotalPercent
CCH 2 Duration2023Fall12580
CCH 2 Duration2023Spring15287
CCH 2 Duration2024Fall10768
CCH 2 Duration2024Spring14182

 

B

ClassNameBeginYearFall Total Fall PercentSpring TotalSpring Percent
CCH 2 Duration20231258015287
CCH 2 Duration20241076814185
1 ACCEPTED SOLUTION
Irwan
Super User
Super User

hello @andya_utah 

 

please check if this accomodate your need.

 

if you want to do this in PQ.

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcnb2UDBScCktSizJzM9T0lEyMjAyBlJuiTk5QMrQyBRIWhgoxergVhtcUJSZlw5SbWoEUm2OU7UJkskG5kDSzAKvWoTJJoYgk42UYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ClassName = _t, BeginYear = _t, Assessment = _t, Total = _t, Percent = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ClassName", type text}, {"BeginYear", Int64.Type}, {"Assessment", type text}, {"Total", Int64.Type}, {"Percent", Int64.Type}}),
#"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"ClassName", "BeginYear", "Assessment"}, "Attribute", "Value"),
#"Merged Columns" = Table.CombineColumns(#"Unpivoted Columns",{"Assessment", "Attribute"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"Merged"),
#"Pivoted Column" = Table.Pivot(#"Merged Columns", List.Distinct(#"Merged Columns"[Merged]), "Merged", "Value", List.Sum)
in
#"Pivoted Column"

1. Unpivot Total and Percent

Irwan_0-1743465871823.png

2. Merge Assessment and Attribut

Irwan_1-1743465911665.png

3. Pivot Merged column using Value column as value in pivot

Irwan_3-1743466024324.png

Irwan_2-1743466004801.png

 

if you want to do this in PBI.

following after merged as above, load the data into PBI, the use matrix visual

Irwan_4-1743466126080.png

Irwan_5-1743466203460.png

 

Hope this will help.

Thank you.

View solution in original post

4 REPLIES 4
andya_utah
New Member

Totally what I needed! Thank you ~~~~

Irwan
Super User
Super User

hello @andya_utah 

 

please check if this accomodate your need.

 

if you want to do this in PQ.

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcnb2UDBScCktSizJzM9T0lEyMjAyBlJuiTk5QMrQyBRIWhgoxergVhtcUJSZlw5SbWoEUm2OU7UJkskG5kDSzAKvWoTJJoYgk42UYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ClassName = _t, BeginYear = _t, Assessment = _t, Total = _t, Percent = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ClassName", type text}, {"BeginYear", Int64.Type}, {"Assessment", type text}, {"Total", Int64.Type}, {"Percent", Int64.Type}}),
#"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"ClassName", "BeginYear", "Assessment"}, "Attribute", "Value"),
#"Merged Columns" = Table.CombineColumns(#"Unpivoted Columns",{"Assessment", "Attribute"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"Merged"),
#"Pivoted Column" = Table.Pivot(#"Merged Columns", List.Distinct(#"Merged Columns"[Merged]), "Merged", "Value", List.Sum)
in
#"Pivoted Column"

1. Unpivot Total and Percent

Irwan_0-1743465871823.png

2. Merge Assessment and Attribut

Irwan_1-1743465911665.png

3. Pivot Merged column using Value column as value in pivot

Irwan_3-1743466024324.png

Irwan_2-1743466004801.png

 

if you want to do this in PBI.

following after merged as above, load the data into PBI, the use matrix visual

Irwan_4-1743466126080.png

Irwan_5-1743466203460.png

 

Hope this will help.

Thank you.

WishAskedSooner
Continued Contributor
Continued Contributor

Nothing complex at all when using PowerQuery. Just bring your table into PBI, and instead of clicking Load, click Transform and edit the query. The UI is your friend.

Thank you for the response - but the "pivot column" function in power query does not allow me to arrive at the result I posted above. Care to enlighten me more as how to accomplish?

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.