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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
paulohk
New Member

Power Query transformation

Hello, 

the following data's are extract from a software and is presented as follow :

Column 1Column 2Column 3Column 4 Lot numberPiece
TEST NAMETEST ATEST BTEST CA000051
SITE01         460.2A000051
SITE02         460.3A000051
TEST NAMETEST ATEST BTEST CA000052
SITE01         250.3A000052
SITE02         260.3A000052

 

With power query, I would like to transport the table to get this, and have the test name in a column  : 

SITETEST NAMEVALUELot numberPiece
SITE01         TEST A4A000051
SITE01         TEST B6A000051
SITE01         TEST C0.2A000051
SITE02         TEST A4A000051
SITE02         TEST B6A000051
SITE02         TEST C0.3A000051
SITE01         TEST A2A000052
SITE01         TEST B5A000052
SITE01         TEST C0.3A000052
SITE02         TEST A2A000052
SITE02         TEST B6A000052
SITE02         TEST C0.3A000052

I supposed it could be usefull to use unpivot function, but i didn't managed to get the good result. Do you have an idea ?

Thanks for your help !

Have a good day.
 

1 ACCEPTED SOLUTION
dufoq3
Super User
Super User

Hi @paulohk, check this:

 

Result

dufoq3_0-1721399790902.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCnENDlHwc/R1VdKBsB1hDCcYwxnIcDQAAlMgw1ApVidaKdgzxNXAUAEGgOImQGwGxAZ6RjiUG2FXboypnFQ3GeFwE8glppiWGOFwkxF2NwGVxwIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Column 1" = _t, #"Column 2" = _t, #"Column 3" = _t, #"Column 4" = _t, #" Lot number" = _t, Piece = _t]),
    PromotedHeaders = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    UnpivotedOtherColumns = Table.UnpivotOtherColumns(PromotedHeaders, {"TEST NAME", "A00005", "1"}, "Attribute", "Value"),
    RenamedColumns = Table.RenameColumns(UnpivotedOtherColumns,{{"TEST NAME", "SITE"}, {"Attribute", "TEST NAME"}, {"A00005", "Lot number"}, {"Value", "VALUE"}, {"1", "Piece"}}),
    FilteredRows = Table.SelectRows(RenamedColumns, each ([SITE] <> "TEST NAME")),
    ReorderedColumns = Table.ReorderColumns(FilteredRows,{"SITE", "TEST NAME", "VALUE", "Lot number", "Piece"})
in
    ReorderedColumns

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 @paulohk, check this:

 

Result

dufoq3_0-1721399790902.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCnENDlHwc/R1VdKBsB1hDCcYwxnIcDQAAlMgw1ApVidaKdgzxNXAUAEGgOImQGwGxAZ6RjiUG2FXboypnFQ3GeFwE8glppiWGOFwkxF2NwGVxwIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Column 1" = _t, #"Column 2" = _t, #"Column 3" = _t, #"Column 4" = _t, #" Lot number" = _t, Piece = _t]),
    PromotedHeaders = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    UnpivotedOtherColumns = Table.UnpivotOtherColumns(PromotedHeaders, {"TEST NAME", "A00005", "1"}, "Attribute", "Value"),
    RenamedColumns = Table.RenameColumns(UnpivotedOtherColumns,{{"TEST NAME", "SITE"}, {"Attribute", "TEST NAME"}, {"A00005", "Lot number"}, {"Value", "VALUE"}, {"1", "Piece"}}),
    FilteredRows = Table.SelectRows(RenamedColumns, each ([SITE] <> "TEST NAME")),
    ReorderedColumns = Table.ReorderColumns(FilteredRows,{"SITE", "TEST NAME", "VALUE", "Lot number", "Piece"})
in
    ReorderedColumns

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

Hoki_34789
New Member

Saya sebagai siswa akuntansi ingin sekali belajar power bi, minta saranya?

Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.