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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Moniek
Resolver I
Resolver I

Unpivot

Hi,

 

I would like to convert a table (Unpivot?) . So that I have a column for amount and hours, like the example below. How can I do it in Power Query, thanks a lot!

 

Moniek_0-1681998257605.png

 

1 ACCEPTED SOLUTION
m_dekorte
Resident Rockstar
Resident Rockstar

Hi @Moniek 

 

Select your columns Index and Name, go to the Transform tab on the ribbon and select: Unpivot Columns, Unpivot Other Columns.

Click on the Attribute column header to select that column, select Split Column, Split by delimiter (space)

Now select the Attribute.2 column and choose Pivot Column set the Value column as Values column

And that should be it!

 

You can copy this script into a new blank query, to see all the steps I've described.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCjFU0lECYwMgYQTCBkqxOkAJIwRfR8kYhC2VYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, #"Jan Hour" = _t, #"Jan Amount" = _t, #"Feb Hour" = _t, #"Feb Amount" = _t]),
    ChType = Table.TransformColumnTypes(Source,{{"Jan Hour", Int64.Type}, {"Jan Amount", Int64.Type}, {"Feb Hour", Int64.Type}, {"Feb Amount", Int64.Type}}),
    UnpivoOtherCols = Table.UnpivotOtherColumns(ChType, {"Name"}, "Attribute", "Value"),
    SplitBySpace = Table.SplitColumn(UnpivoOtherCols, "Attribute", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, false), {"Attribute.1", "Attribute.2"}),
    PivotedCol = Table.Pivot(SplitBySpace, List.Distinct(SplitBySpace[Attribute.2]), "Attribute.2", "Value", List.Sum)
in
    PivotedCol

 

Ps. If this helps solve your query please mark this post as Solution, thanks!

View solution in original post

1 REPLY 1
m_dekorte
Resident Rockstar
Resident Rockstar

Hi @Moniek 

 

Select your columns Index and Name, go to the Transform tab on the ribbon and select: Unpivot Columns, Unpivot Other Columns.

Click on the Attribute column header to select that column, select Split Column, Split by delimiter (space)

Now select the Attribute.2 column and choose Pivot Column set the Value column as Values column

And that should be it!

 

You can copy this script into a new blank query, to see all the steps I've described.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCjFU0lECYwMgYQTCBkqxOkAJIwRfR8kYhC2VYmMB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, #"Jan Hour" = _t, #"Jan Amount" = _t, #"Feb Hour" = _t, #"Feb Amount" = _t]),
    ChType = Table.TransformColumnTypes(Source,{{"Jan Hour", Int64.Type}, {"Jan Amount", Int64.Type}, {"Feb Hour", Int64.Type}, {"Feb Amount", Int64.Type}}),
    UnpivoOtherCols = Table.UnpivotOtherColumns(ChType, {"Name"}, "Attribute", "Value"),
    SplitBySpace = Table.SplitColumn(UnpivoOtherCols, "Attribute", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, false), {"Attribute.1", "Attribute.2"}),
    PivotedCol = Table.Pivot(SplitBySpace, List.Distinct(SplitBySpace[Attribute.2]), "Attribute.2", "Value", List.Sum)
in
    PivotedCol

 

Ps. If this helps solve your query please mark this post as Solution, thanks!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.