Excel formatting problem pivot/unpivot

Anunay

New Member
Joined
May 4, 2022
Messages
9
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
This is the source format i have which i have tried picoting and unpivoting and even transposing for some reason to make it work in the format i have attached below i have even reached a point where my excel looks almost like the output but then the batch numbers are missing.


Order Problem Source.xlsx
ABCDEF
1944179441894419
2Item TypeItem NoItem DescriptionCompletedCompletedWIP
3IngredientsF2200000000TKBatter1.0002.0003.000
4IngredientsF220000000000Honey2.0003.0004.000
5IngredientsF22000000FXTKChocoChip3.0004.0005.000
Sheet1




This is output i want


Order Problem Source.xlsx
ABCDEF
1Order Batch IDItem TypeItem NoItem DescriptionQtyStatus
2Batch NoItem TypeItem NoItem DescriptionQtyStatus
394417IngredientsF2200000000TKBatter1Completed
494417IngredientsF2200000000TKBatter2Completed
594417IngredientsF2200000000TKBatter3WIP
694418IngredientsF220000000000Honey1Completed
794418IngredientsF220000000000Honey2Completed
894418IngredientsF220000000000Honey3WIP
994419IngredientsF22000000FXTKChocoChip3Completed
1094419IngredientsF22000000FXTKChocoChip4Completed
1194419IngredientsF22000000FXTKChocoChip5WIP
Sheet2



This is my solution which is not complete as the order batch id column went missing after the unpivoting steps.

Book3
ABCDE
1Item TypeItem NoItem DescriptionAttributeValue
2IngredientsF2200000000TKBatterCompleted1
3IngredientsF2200000000TKBatterComplete2
4IngredientsF2200000000TKBatterWIP3
5IngredientsF220000000000HoneyCompleted2
6IngredientsF220000000000HoneyComplete3
7IngredientsF220000000000HoneyWIP4
8IngredientsF22000000FXTKChocochipCompleted3
9IngredientsF22000000FXTKChocochipComplete4
10IngredientsF22000000FXTKChocochipWIP5
Table1
 

Attachments

  • MY SOLUTION.jpg
    MY SOLUTION.jpg
    142 KB · Views: 8

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Here is a power query version.
You do need to convert the data to a table first and in that process unclick the Table has headers. You can then unclick the Table Design > Header Row, to hide the Column1, Column2 etc row it creates.
If you call your table "tblData", then you can use the query as is, otherwise just change the source to your table name.

PS: This technique is used by Leila Gharan ref:

Wyn Hopkins uses a slightly different technique using a Range Name instead of a table name


Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="tblData"]}[Content],
    #"Merged Columns" = Table.CombineColumns(Source,{"Column1", "Column2", "Column3"},Combiner.CombineTextByDelimiter("|", QuoteStyle.None),"Merged"),
    #"Transposed Table" = Table.Transpose(#"Merged Columns"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Promoted Headers", {"Item Type|Item No|Item Description", "||"}, "Attribute", "Value"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv), {"Attribute.1", "Attribute.2", "Attribute.3"}),
    #"Renamed Columns" = Table.RenameColumns(#"Split Column by Delimiter",{{"||", "Order Batch ID"}, {"Item Type|Item No|Item Description", "Status"}, {"Attribute.1", "Item Type"}, {"Attribute.2", "Item No"}, {"Attribute.3", "Item Description"}, {"Value", "Qty"}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns",{"Order Batch ID", "Item Type", "Item No", "Item Description", "Qty", "Status"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Reordered Columns",{{"Order Batch ID", Int64.Type}, {"Item Type", type text}, {"Item No", type text}, {"Item Description", type text}, {"Qty", Int64.Type}, {"Status", type text}})
in
    #"Changed Type"
 
Upvote 0
Solution
When you enter power query you automatically convert the selected data into a table, I couldn't cogently understand your solution tbh.
 
Upvote 0
Here is a power query version.
You do need to convert the data to a table first and in that process unclick the Table has headers. You can then unclick the Table Design > Header Row, to hide the Column1, Column2 etc row it creates.
If you call your table "tblData", then you can use the query as is, otherwise just change the source to your table name.

PS: This technique is used by Leila Gharan ref:

Wyn Hopkins uses a slightly different technique using a Range Name instead of a table name


Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="tblData"]}[Content],
    #"Merged Columns" = Table.CombineColumns(Source,{"Column1", "Column2", "Column3"},Combiner.CombineTextByDelimiter("|", QuoteStyle.None),"Merged"),
    #"Transposed Table" = Table.Transpose(#"Merged Columns"),
    #"Promoted Headers" = Table.PromoteHeaders(#"Transposed Table", [PromoteAllScalars=true]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Promoted Headers", {"Item Type|Item No|Item Description", "||"}, "Attribute", "Value"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv), {"Attribute.1", "Attribute.2", "Attribute.3"}),
    #"Renamed Columns" = Table.RenameColumns(#"Split Column by Delimiter",{{"||", "Order Batch ID"}, {"Item Type|Item No|Item Description", "Status"}, {"Attribute.1", "Item Type"}, {"Attribute.2", "Item No"}, {"Attribute.3", "Item Description"}, {"Value", "Qty"}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns",{"Order Batch ID", "Item Type", "Item No", "Item Description", "Qty", "Status"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Reordered Columns",{{"Order Batch ID", Int64.Type}, {"Item Type", type text}, {"Item No", type text}, {"Item Description", type text}, {"Qty", Int64.Type}, {"Status", type text}})
in
    #"Changed Type"
here's my personal mail anunaysharma1@gmail.com send me a mail and maybe if you got time we'll connect on meet and you could show me how to do this, because i'm going berserk not being able to solve this.
 
Upvote 0
Ignore all replies this was mad genius. I did it. It worked!!!!!
 
Upvote 0

Forum statistics

Threads
1,223,732
Messages
6,174,182
Members
452,550
Latest member
southernsquid2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top