Unstack data , grouping by ID complex problem

Michael255

New Member
Joined
Aug 15, 2019
Messages
5
Hello,

In my file, for each ID i've got 10-15 rows with duplicate data in diffrent column, i need to insert all the data for each ID to 1 row, i tried in few ways but i don't know how to solve this, could anyone help me with this task, i tried on 2 diffrent forum without results

https://gofile.io/?c=QADt6Q - link for excel file
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
I see error only:
[highlight]DataSource.Error: Could not find a part of the path 'C:\Users\michal.parciak\Downloads\CUC_transpose\Kopia testowy.xlsx'.[/highlight]

and I have no access to the query-tables in PQ Editor.

The data on sheet1 can be treated as source?
 
Upvote 0
sure, if you describe with details what you want to achieve.

first of all you can group a few columns and you'll get 155 rows instead 391
 
Upvote 0
Sandy, its still too much, i need for 1 specification ID== 1 row of data, it can be ultra long but for 50k rows its gonna help me a lot to input data to SAP. Is this possible to transform for ID to 1 row?
 
Upvote 0
I assumed Specification is ID (because ID doesn't exist in your source table), so M-code is:
Code:
[SIZE=1]// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Type = Table.TransformColumnTypes(Source,{{"Specification", type text}, {"Material", type any}, {"Change Number", type text}, {"Valid From", type date}, {"Valid To", type date}, {"Description", type text}, {"Property Tree", type text}, {"Level 1", type text}, {"Level 2", type text}, {"Level 3", type text}, {"Specification2", type any}, {"Property", type text}, {"Field", type text}, {"Sequence", Int64.Type}, {"Validity Area", type text}, {"Difference", type any}, {"Value", type text}}),
    Replace = Table.ReplaceValue(Table.SelectRows(Table.ReplaceValue(Table.ReplaceValue(Table.ReplaceValue(Table.ReplaceValue(Type,"",null,Replacer.ReplaceValue,{"Material", "Level 3", "Specification2", "Difference"}),"<blank>",null,Replacer.ReplaceValue,{"Value"}),"",null,Replacer.ReplaceValue,{"Value"}),"",null,Replacer.ReplaceValue,{"Specification", "Material", "Change Number", "Valid From", "Valid To", "Description", "Property Tree", "Level 1", "Level 2", "Level 3", "Specification2", "Property", "Field", "Sequence", "Validity Area", "Difference", "Value"}), each ([Specification] <> null)),"",null,Replacer.ReplaceValue,{"Specification", "Material", "Change Number", "Valid From", "Valid To", "Description", "Property Tree", "Level 1", "Level 2", "Level 3", "Specification2", "Property", "Field", "Sequence", "Validity Area", "Difference", "Value"}),
    Group = Table.Group(Replace, {"Specification", "Material", "Change Number", "Valid From", "Valid To", "Description", "Property Tree", "Specification2", "Difference"}, {{"Count", each _, type table}}),
    Level1 = Table.SplitColumn(Table.TransformColumns(Table.AddColumn(Group, "Level 1", each List.Distinct(Table.Column([Count],"Level 1"))), {"Level 1", each Text.Combine(List.Transform(_, Text.From), "="), type text}), "Level 1", Splitter.SplitTextByDelimiter("=", QuoteStyle.Csv), {"Level 1.1", "Level 1.2", "Level 1.3", "Level 1.4", "Level 1.5"}),
    Level2 = Table.SplitColumn(Table.TransformColumns(Table.AddColumn(Level1, "Level 2", each List.Distinct(Table.Column([Count],"Level 2"))), {"Level 2", each Text.Combine(List.Transform(_, Text.From), "="), type text}), "Level 2", Splitter.SplitTextByDelimiter("=", QuoteStyle.Csv), {"Level 2.1", "Level 2.2", "Level 2.3", "Level 2.4", "Level 2.5", "Level 2.6"}),
    Level3 = Table.SplitColumn(Table.TransformColumns(Table.AddColumn(Level2, "Level 3", each List.Distinct(Table.Column([Count],"Level 3"))), {"Level 3", each Text.Combine(List.Transform(_, Text.From), "="), type text}), "Level 3", Splitter.SplitTextByDelimiter("=", QuoteStyle.Csv), {"Level 3.1", "Level 3.2"}),
    Property = Table.SplitColumn(Table.TransformColumns(Table.AddColumn(Level3, "Property", each List.Distinct(Table.Column([Count],"Property"))), {"Property", each Text.Combine(List.Transform(_, Text.From), "="), type text}), "Property", Splitter.SplitTextByDelimiter("=", QuoteStyle.Csv), {"Property.1", "Property.2", "Property.3", "Property.4", "Property.5", "Property.6", "Property.7", "Property.8", "Property.9", "Property.10", "Property.11", "Property.12", "Property.13"}),
    Field = Table.SplitColumn(Table.TransformColumns(Table.AddColumn(Property, "Field", each List.Distinct(Table.Column([Count],"Field"))), {"Field", each Text.Combine(List.Transform(_, Text.From), "="), type text}), "Field", Splitter.SplitTextByDelimiter("=", QuoteStyle.Csv), {"Field.1", "Field.2", "Field.3", "Field.4"}),
    Sequence = Table.SplitColumn(Table.TransformColumns(Table.AddColumn(Field, "Sequence", each List.Distinct(Table.Column([Count],"Sequence"))), {"Sequence", each Text.Combine(List.Transform(_, Text.From), "="), type text}), "Sequence", Splitter.SplitTextByDelimiter("=", QuoteStyle.Csv), {"Sequence.1", "Sequence.2", "Sequence.3", "Sequence.4", "Sequence.5", "Sequence.6"}),
    ValidityArea = Table.SplitColumn(Table.TransformColumns(Table.AddColumn(Sequence, "Validity Area", each List.Distinct(Table.Column([Count],"Validity Area"))), {"Validity Area", each Text.Combine(List.Transform(_, Text.From), "="), type text}), "Validity Area", Splitter.SplitTextByDelimiter("=", QuoteStyle.Csv), {"Validity Area.1", "Validity Area.2"}),
    Value = Table.SplitColumn(Table.TransformColumns(Table.AddColumn(ValidityArea, "Value", each List.Distinct(Table.Column([Count],"Value"))), {"Value", each Text.Combine(List.Transform(_, Text.From), "="), type text}), "Value", Splitter.SplitTextByDelimiter("=", QuoteStyle.Csv), {"Value.1", "Value.2", "Value.3", "Value.4", "Value.5", "Value.6", "Value.7", "Value.8", "Value.9", "Value.10", "Value.11", "Value.12", "Value.13", "Value.14", "Value.15", "Value.16", "Value.17", "Value.18", "Value.19", "Value.20", "Value.21", "Value.22", "Value.23", "Value.24", "Value.25", "Value.26", "Value.27", "Value.28"})
in
    Value[/SIZE]
SpecificationMaterialChange NumberValid FromValid ToDescriptionProperty TreeSpecification2DifferenceLevel 1.1Level 1.2Level 1.3Level 1.4Level 1.5Level 2.1Level 2.2Level 2.3Level 2.4Level 2.5Level 2.6Level 3.1Level 3.2Property.1Property.2Property.3Property.4Property.5Property.6Property.7Property.8Property.9Property.10Property.11Property.12Property.13Field.1Field.2Field.3Field.4Sequence.1Sequence.2Sequence.3Sequence.4Sequence.5Sequence.6Validity Area.1Validity Area.2Value.1Value.2Value.3Value.4Value.5Value.6Value.7Value.8Value.9Value.10Value.11Value.12Value.13Value.14Value.15Value.16Value.17Value.18Value.19Value.20Value.21Value.22Value.23Value.24Value.25Value.26Value.27Value.28
200000131641300003066037
09/08/2019​
31/12/9999​
CUC WSp-Asep Tomato Mozz 02 Safi GblZCUC_SAVR3Bulk Storage and DistributionChemical-Physical AnalysisConsumer Information / ClaimsNutritionStorage / Distribution ConditionsChemical-Physical AnalysisFood Allergen / Food IntoleranceFoods Free fromNutritional DataStorage TemperatureTransport TemperatureViscosity mPaspHAlcoholIrradiationMeatCarbohydrateEnergy kJEnergy kcalProteinMaxMinUoMCondition Set1WORLD255°C200Undefined120165mPas4.4ISO-18424.154.3valueXCalculation5.449400g267.155500kJ45.820200kcal1.054800
200000135924300002628673
07/05/2019​
31/12/9999​
CUC Ketch-Red 50 Honey no presZCUC_SAVR3Bulk Storage and DistributionChemical-Physical AnalysisConsumer Information / ClaimsNutritionProcess DescriptionStorage / Distribution ConditionsChemical-Physical AnalysisFood Allergen / Food IntoleranceFoods Free fromNutritional DataWarning LevelsChemical-Physical AnalysisShelf Life Total MonthsStorage TemperatureTransport TemperatureDensity 20 °CpHAlcoholIrradiationMeatCarbohydrateEnergy kJEnergy kcalProteinDelivery ConditionMaxUoMMin12WORLDEUFP - Bottle12month(s)255°C301.11Undefined1.071.09g/cm33.9ISO-18423.73.8valueXCalculation15.661512g321.223350kJ75.606550kcal1.7349533.753.95
200000137914300002618441
30/04/2019​
31/12/9999​
CUC WSp-Asep Tomato Cream 01ZCUC_SAVR3Bulk Storage and DistributionChemical-Physical AnalysisConsumer Information / ClaimsNutritionStorage / Distribution ConditionsChemical-Physical AnalysisFoods Free fromNutritional DataShelf Life Total MonthsStorage TemperatureTransport TemperatureDensity 20 °CpHAlcoholIrradiationMeatCarbohydrateEnergy kJEnergy kcalProteinDelivery ConditionMaxUoMMin178WORLDEUFP - Carton14month(s)255°CUndefined1.037g/cm35.0ISO-18424.54.75valueXCalculation6.826050g216.363288kJ53.380223kcal1.475924
200000208244300002620951
01/05/2019​
31/12/9999​
CUC WSp-Asep Mushr Girolle Pancetta 01ZCUC_SAVR3Bulk Storage and DistributionChemical-Physical AnalysisConsumer Information / ClaimsNutritionStorage / Distribution ConditionsChemical-Physical AnalysisFood Allergen / Food IntoleranceFoods Free fromNutritional DataShelf Life Total MonthsStorage TemperatureTransport TemperatureDensity 20 °CpHAlcoholIrradiationMeatCarbohydrateEnergy kJEnergy kcalProteinDelivery ConditionMaxUoMMin123456WORLDEUFP - Carton9month(s)255°CUndefined1.0205g/cm3ISO-18425.63valueX0.100000mg/kgCalculation4.514100g249.644200kJ58.450600kcal1.347100
200000211851300003066182
08/08/2019​
31/12/9999​
CUC WSp-Asp. F. Poeles VegZCUC_SAVR3Bulk Storage and DistributionChemical-Physical AnalysisConsumer Information / ClaimsNutritionStorage / Distribution ConditionsChemical-Physical AnalysisFoods Free fromNutritional DataShelf Life Total MonthsStorage TemperatureTransport TemperatureDensity 20 °CViscosity mPaspHAlcoholIrradiationMeatCarbohydrateEnergy kJEnergy kcalProteinDelivery ConditionMaxUoMMin123WORLDEUFP - Carton12month(s)255°CUndefined1.0310g/cm3mPas5.7ISO-18425.55.6valueXCalculation6.094100g194.710200kJ44.716100kcal0.647700
200000213712300002646963
09/05/2019​
31/12/9999​
CUC WSp-Asep Mixed 8 VegZCUC_SAVR3Bulk Storage and DistributionChemical-Physical AnalysisConsumer Information / ClaimsNutritionStorage / Distribution ConditionsChemical-Physical AnalysisFoods Free fromNutritional DataShelf Life Total MonthsStorage TemperatureTransport TemperatureDensity 20 °CAlcoholIrradiationMeatCarbohydrateEnergy kJEnergy kcalProteinDelivery ConditionMaxUoMMin1256WORLDEUFP - Bottle9month(s)255°CUndefined1.0370g/cm3XCalculation7.305012g267.215034kJ63.875035kcal0.814172
200000234242
31/12/9999​
CUC WSp-Doy Tomato HerbyZCUC_SAVR3Bulk Storage and DistributionChemical-Physical AnalysisConsumer Information / ClaimsNutritionStorage / Distribution ConditionsChemical-Physical AnalysisFoods Free fromNutritional DataShelf Life Total MonthsStorage TemperatureTransport TemperatureDensity 20 °CpHAlcoholIrradiationMeatCarbohydrateEnergy kJEnergy kcalProteinDelivery ConditionMaxUoMMin123WORLDEUFP - Pouch12month(s)255°CUndefined1.035g/cm34.4ISO-18424.24.3valueXCalculation4.465597g175.405883kJ41.429993kcal0.600946
200000234297
31/12/9999​
CUC WSp-Doy 570ml Broccoli organicZCUC_SAVR3Bulk Storage and DistributionChemical-Physical AnalysisConsumer Information / ClaimsNutritionStorage / Distribution ConditionsChemical-Physical AnalysisFoods Free fromNutritional DataShelf Life Total MonthsStorage TemperatureTransport TemperatureDensity 20 °CpHAlcoholIrradiationMeatCarbohydrateEnergy kJEnergy kcalProteinDelivery ConditionMaxUoMMin123WORLDEUFP - Pouch12month(s)255°CUndefined1.0180g/cm36ISO-18425.45.7valueXCalculation3.512383g199.457830kJ47.346081kcal1.206850
reorder columns as you wish
Excel example file
 
Upvote 0

Forum statistics

Threads
1,214,394
Messages
6,119,263
Members
448,881
Latest member
Faxgirl

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