Search code examples
excelms-office

How to achieve this special kind of transpose in excel?


I have this data sheet here in this specific table structure ...

enter image description here

The goal is to extract Vorname, Nachname, Barcode into a separate sheet but in this transposed structure ...

enter image description here

I tried transpose and then manipulating the arguments to achieve the goal, but nothing worked, and I couldn't find a tutorial online that goes along with my case here.

Tables in text:

Start:

Vorname       Nachname         Barcode
Ahmed         Mahmoud          barcode1
Zakaria       Atef             barcode2

Goal:

Vorname       Ahmed
Nachname      Mahmoud
Barcode       barcode1
Vorname       Zakaria
Nachname      Atef
Barcode       barcode2

Solution

  • This is a simple UNPIVOT operation. Easily handled with Power Query, available in Windows Excel 2010+ or Office 365

    • Select some cell in your Data Table
    • Data => Get&Transform => from Table/Range
    • Select ALL the columns, then Transform => Unpivot

    and your done.

    M Code

    let
        Source = Excel.CurrentWorkbook(){[Name="Table12"]}[Content],
        #"Changed Type" = Table.TransformColumnTypes(Source,{
            {"Vorname", type text}, {"Nachname", type text}, {"Barcode", type text}}),
        #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {}, "Attribute", "Value")
    in
        #"Unpivoted Columns"
    

    Source
    enter image description here

    Results
    enter image description here