Arrange (Transpose) Single Row to Multiple Row Based on Criteria

ESCAAGROVET

New Member
Joined
Jan 30, 2021
Messages
10
Office Version
  1. 2019
Platform
  1. Windows
Hi Friends,
I have Product Data in Single Row in following order (data in tabular form at end of sheet)

Sample data.png


Above data is required to be sorted in new sheet as following
Sample Output.png


1. Row number 2,3,4, are for refrence only. Not Required In actual output
2. If Varient 1 or varient 2 Data is blank it needs to be skipped

Your help will be of immense help.
Thanks to all of you in advance for giving precious time of yours.




#Unique IDVariant IDItem NameVendorCategoryPackingPacking UnitWeight (gm)BarcodeImageHSNTax RateVarient ID 1PackingPacking Unit 1Weight 1Varient ID 2PackingPacking Unit 2Weight 2
11000010000ITEM AVEND 1CATG 1Packing10Kg1000010000 11010010000 BPacking5Kg500010000 CPacking50Kg50000
21000110001ITEM BVEND 2CATG 2Packing100Kg10000010001 11020010001 BPacking15Kg15000
31000210002ITEM CVEND 3CATG 3Packing1000Kg100000010002 110300
41000310003ITEM DVEND 4CATG 4Packing10001Kg100010010003https://cdn.shopify.com/s/files/1/0270/5499/7569/products/ARAROTLOOSE.jpg?v=1607366548110400
 
Last edited by a moderator:

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
With the exception of Sold by Weight, I believe the following Mcode accomplishes what you are looking for. This is a Power Query Solution

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type any}, {"Column2", type any}, {"Column3", type any}, {"Column4", type text}, {"Column5", type text}, {"Column6", type text}, {"Column7", type text}, {"Column8", type text}, {"Column9", type any}, {"Column10", type any}, {"Column11", type text}, {"Column12", type any}, {"Column13", type any}, {"Column14", type text}, {"Column15", type text}, {"Column16", type text}, {"Column17", type any}, {"Column18", type text}, {"Column19", type text}, {"Column20", type text}, {"Column21", type any}}),
    #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"#", Int64.Type}, {"Unique ID", Int64.Type}, {"Variant ID", Int64.Type}, {"Item Name", type text}, {"Vendor", type text}, {"Category", type text}, {"Packing", type text}, {"Packing Unit", type text}, {"Weight (gm)", Int64.Type}, {"Barcode", Int64.Type}, {"Image", type text}, {"HSN", Int64.Type}, {"Tax Rate", Int64.Type}, {"Varient ID 1", type text}, {"Packing_1", type text}, {"Packing Unit 1", type text}, {"Weight 1", Int64.Type}, {"Varient ID 2", type text}, {"Packing_2", type text}, {"Packing Unit 2", type text}, {"Weight 2", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type1", {"Unique ID", "Variant ID", "Item Name", "Category"}, "Attribute", "Value"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Other Columns", each Text.StartsWith([Attribute], "Packing Unit"))
in
    #"Filtered Rows"

Need to only change the Field Names for the last two columns.

Book1
ABCDEF
1Unique IDVariant IDItem NameCategoryAttributeValue
21000010000ITEM ACATG 1Packing Unit10Kg
31000010000ITEM ACATG 1Packing Unit 15Kg
41000010000ITEM ACATG 1Packing Unit 250Kg
51000110001ITEM BCATG 2Packing Unit100Kg
61000110001ITEM BCATG 2Packing Unit 115Kg
71000210002ITEM CCATG 3Packing Unit1000Kg
81000310003ITEM DCATG 4Packing Unit10001Kg
Table1
 
Upvote 0
With the exception of Sold by Weight, I believe the following Mcode accomplishes what you are looking for. This is a Power Query Solution

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type any}, {"Column2", type any}, {"Column3", type any}, {"Column4", type text}, {"Column5", type text}, {"Column6", type text}, {"Column7", type text}, {"Column8", type text}, {"Column9", type any}, {"Column10", type any}, {"Column11", type text}, {"Column12", type any}, {"Column13", type any}, {"Column14", type text}, {"Column15", type text}, {"Column16", type text}, {"Column17", type any}, {"Column18", type text}, {"Column19", type text}, {"Column20", type text}, {"Column21", type any}}),
    #"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"#", Int64.Type}, {"Unique ID", Int64.Type}, {"Variant ID", Int64.Type}, {"Item Name", type text}, {"Vendor", type text}, {"Category", type text}, {"Packing", type text}, {"Packing Unit", type text}, {"Weight (gm)", Int64.Type}, {"Barcode", Int64.Type}, {"Image", type text}, {"HSN", Int64.Type}, {"Tax Rate", Int64.Type}, {"Varient ID 1", type text}, {"Packing_1", type text}, {"Packing Unit 1", type text}, {"Weight 1", Int64.Type}, {"Varient ID 2", type text}, {"Packing_2", type text}, {"Packing Unit 2", type text}, {"Weight 2", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type1", {"Unique ID", "Variant ID", "Item Name", "Category"}, "Attribute", "Value"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Other Columns", each Text.StartsWith([Attribute], "Packing Unit"))
in
    #"Filtered Rows"

Need to only change the Field Names for the last two columns.

Book1
ABCDEF
1Unique IDVariant IDItem NameCategoryAttributeValue
21000010000ITEM ACATG 1Packing Unit10Kg
31000010000ITEM ACATG 1Packing Unit 15Kg
41000010000ITEM ACATG 1Packing Unit 250Kg
51000110001ITEM BCATG 2Packing Unit100Kg
61000110001ITEM BCATG 2Packing Unit 115Kg
71000210002ITEM CCATG 3Packing Unit1000Kg
81000310003ITEM DCATG 4Packing Unit10001Kg
Table1
Thanks for your time,
Item Name, Category & Packing should not repeat in output. Kindly help when possible.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,155
Members
453,021
Latest member
Justyna P

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