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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
WishAskedSooner
Continued Contributor
Continued Contributor

Unpivot and Normalize

Hi Experts!

 

I am a complete newbie to Power Query. I am eager to learn and have a complicated unpivoting problem.

 

I have pivoted data in the following format (it's not my data):

ProdPriceInvProdPriceInv
A110B220

 

I can easily unpivot in PQ to the following:

ProdA
Price1
Inv10
ProdB
Price2
Inv20

 

Now, I need to normalize the above output:

ProdAttrValue
APrice1
AInv10
BPrice2
BInv20

 

Is there an easy way to normalize the data using Power Query? Thanks in advance for the help!

1 ACCEPTED SOLUTION
dufoq3
Super User
Super User

Hi @WishAskedSooner, another solution:

 

Result

dufoq3_0-1721808347899.png

 

You have to enter number of columns for split:

dufoq3_1-1721808761047.png

dufoq3_2-1721808814382.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIEYQMg4QTERiBsoBQbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Prod = _t, Price = _t, Inv = _t, Prod.1 = _t, Price.1 = _t, Inv.1 = _t]),
    Transformed = Table.Combine(List.Transform(List.Split(Table.ToColumns(Source), 3), (x)=> Table.UnpivotOtherColumns(Table.FromColumns(x, {"Prod", "Price", "Inv"}), {"Prod"}, "Attr", "Value")))
in
    Transformed

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

2 REPLIES 2
dufoq3
Super User
Super User

Hi @WishAskedSooner, another solution:

 

Result

dufoq3_0-1721808347899.png

 

You have to enter number of columns for split:

dufoq3_1-1721808761047.png

dufoq3_2-1721808814382.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIEYQMg4QTERiBsoBQbCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Prod = _t, Price = _t, Inv = _t, Prod.1 = _t, Price.1 = _t, Inv.1 = _t]),
    Transformed = Table.Combine(List.Transform(List.Split(Table.ToColumns(Source), 3), (x)=> Table.UnpivotOtherColumns(Table.FromColumns(x, {"Prod", "Price", "Inv"}), {"Prod"}, "Attr", "Value")))
in
    Transformed

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

wdx223_Daniel
Community Champion
Community Champion

NewStep=Table.Combine(Table.Group(YourCurrentUnpivotedTable,"Column1",{"n",each Table.AddColumn(Table.Skip(_),"Prod",(x)=>_{0}[Column1])},0,(x,y)=>Byte.From(y="Prod"))[n])

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

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.