Partial Transform

mrmdsims

New Member
Joined
Apr 8, 2020
Messages
8
Office Version
  1. 2016
Platform
  1. Windows
I have a table of orders where the items in the order are all on one line. I need to have each item on its own line along with the order number and date. Some orders could have up to 253 items but of course, I do not want to transform the ones that are blank. Power Query got me very close but I could not change Item, Description, and Quantity to a column and have the values below.

Any help would be appreciated.

Mike
 

Attachments

  • Annotation 2020-04-08 180653.png
    Annotation 2020-04-08 180653.png
    32.6 KB · Views: 14

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
I suggest to post your example data with XL2BB, nobody want to retype your data from the picture
 
Upvote 0
Here is the spreadsheet. Thanks Sandy666

Order Info.xlsx
BCDEFGHIJKLM
1From This
2OrderDateItem -1 Item - 1 DescriptionItem - 1 QuantityItem -2Item -2 DecriptionItem -2 QuantityItem -3Item -3 DescriptionItem -3 Quantity
31234564/8/2020ABCABC Thing1DEFDEF Thing3XYZXYZ Thing200
44567894/8/2020ABCABC Thing4
51237894/8/2020DEFDEF Thing3XYZXYZ Thing2
6
7To This
8OrderDateItemDescriptionQuantity
91234564/8/2020ABCABC Thing1
101234564/8/2020DEFDEF Thing3
111234564/8/2020XYZXYZ Thing200
124567894/8/2020ABCABC Thing4
131237894/8/2020DEFDEF Thing3
141237894/8/2020XYZXYZ Thing2
Sheet2
 
Upvote 0
OrderDateItem -1 Item - 1 DescriptionItem - 1 QuantityItem -2Item -2 DescriptionItem -2 QuantityItem -3Item -3 DescriptionItem -3 QuantityOrderDateItemDescriptionQuantity
12345609/04/2020ABCABC Thing1DEFDEF Thing3XYZXYZ Thing20012345609/04/2020ABCABC Thing1
45678909/04/2020ABCABC Thing412345609/04/2020DEFDEF Thing3
12378909/04/2020DEFDEF Thing3XYZXYZ Thing212345609/04/2020XYZXYZ Thing200
45678909/04/2020ABCABC Thing4
12378909/04/2020DEFDEF Thing3
12378909/04/2020XYZXYZ Thing2

Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    UOC = Table.UnpivotOtherColumns(Source, {"Order", "Date"}, "Attribute", "Value"),
    Integer = Table.TransformColumns(Table.AddIndexColumn(UOC, "Index", 0, 1), {{"Index", each Number.IntegerDivide(_, 3), Int64.Type}}),
    List = Table.AddColumn(Table.Group(Integer, {"Order", "Date", "Index"}, {{"Count", each _, type table}}), "Custom", each List.Distinct([Count][Value])),
    Extract = Table.TransformColumns(List, {"Custom", each Text.Combine(List.Transform(_, Text.From), "="), type text}),
    Split = Table.SplitColumn(Extract, "Custom", Splitter.SplitTextByDelimiter("=", QuoteStyle.Csv), {"Custom.1", "Custom.2", "Custom.3"}),
    Rename = Table.RenameColumns(Split,{{"Custom.1", "Item"}, {"Custom.2", "Description"}, {"Custom.3", "Quantity"}}),
    Type = Table.TransformColumnTypes(Table.SelectColumns(Rename,{"Order", "Date", "Item", "Description", "Quantity"}),{{"Date", type date}})
in
    Type
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,213
Members
452,618
Latest member
Tam84

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