Special Unpivot Columns

johnmpl

Board Regular
Joined
Jun 14, 2013
Messages
237
Office Version
  1. 365
Platform
  1. Windows
Hi, to all!

I need to special unpivot some data.

Input:

NAMEANAMEBNAMECDATE THING 1DESCRIPTIONDATE THING 2DESCRIPTION 2DATE THING 3DESCRIPTION 3
Name1Name28Name5528/01/2019Descript 124/02/2019Descript 2823/03/2019Descript 55
Name2Name29Name5629/01/2019Descript 224/03/2019Descript 56
Name3Name30Name5730/01/2019Descript 326/02/2019Descript 30
Name4Name31Name5831/01/2019Descript 4
Name5Name32Name5928/02/2019Descript 3227/03/2019Descript 59

<colgroup><col span="3"><col><col><col><col><col><col></colgroup><tbody>
</tbody>


Output:

NAMEANAMEBNAMECTYPEDATEDESCRIPTION
Name1Name28Name55THING 128/01/2019Descript 1
Name1Name28Name55THING 224/02/2019Descript 28
Name1Name28Name55THING 323/03/2019Descript 55
Name2Name29Name56THING 129/01/2019Descript 2
Name2Name29Name56THING 324/03/2019Descript 56
Name3Name30Name57THING 130/01/2019Descript 3
Name3Name30Name57THING 226/02/2019Descript 30
Name4Name31Name58THING 131/01/2019Descript 4
Name5Name32Name59THING 228/02/2019Descript 32
Name5Name32Name59THING 327/03/2019Descript 59

<colgroup><col><col span="2"><col span="2"><col></colgroup><tbody>
</tbody>

Appreciate all your help. Blessings!
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
NAMEANAMEBNAMECTypeDateDescription
Name1Name28Name55THING 1
28/01/2019​
Descript 1
Name1Name28Name55THING 1
28/01/2019​
Descript 28
Name1Name28Name55THING 1
28/01/2019​
Descript 55
Name1Name28Name55THING 2
24/02/2019​
Descript 1
Name1Name28Name55THING 2
24/02/2019​
Descript 28
Name1Name28Name55THING 2
24/02/2019​
Descript 55
Name1Name28Name55THING 3
23/03/2019​
Descript 1
Name1Name28Name55THING 3
23/03/2019​
Descript 28
Name1Name28Name55THING 3
23/03/2019​
Descript 55
Name2Name29Name56THING 1
29/01/2019​
Descript 2
Name2Name29Name56THING 1
29/01/2019​
Descript 56
Name2Name29Name56THING 3
24/03/2019​
Descript 2
Name2Name29Name56THING 3
24/03/2019​
Descript 56
Name3Name30Name57THING 1
30/01/2019​
Descript 3
Name3Name30Name57THING 1
30/01/2019​
Descript 30
Name3Name30Name57THING 2
26/02/2019​
Descript 3
Name3Name30Name57THING 2
26/02/2019​
Descript 30
Name4Name31Name58THING 1
31/01/2019​
Descript 4
Name5Name32Name59THING 2
28/02/2019​
Descript 32
Name5Name32Name59THING 2
28/02/2019​
Descript 59
Name5Name32Name59THING 3
27/03/2019​
Descript 32
Name5Name32Name59THING 3
27/03/2019​
Descript 59

Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table5"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"NAMEA", type text}, {"NAMEB", type text}, {"NAMEC", type text}, {"DATE THING 1", type datetime}, {"DESCRIPTION", type text}, {"DATE THING 2", type datetime}, {"DESCRIPTION 2", type text}, {"DATE THING 3", type datetime}, {"DESCRIPTION 3", type text}}),
    #"Unpivoted Only Selected Columns" = Table.Unpivot(#"Changed Type", {"DATE THING 1", "DATE THING 2", "DATE THING 3"}, "Attribute", "Value"),
    #"Unpivoted Only Selected Columns1" = Table.Unpivot(#"Unpivoted Only Selected Columns", {"DESCRIPTION", "DESCRIPTION 2", "DESCRIPTION 3"}, "Attribute.1", "Value.1"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Only Selected Columns1",{{"Attribute", "Type"}, {"Value", "Date"}}),
    #"Removed Columns" = Table.RemoveColumns(#"Renamed Columns",{"Attribute.1"}),
    #"Renamed Columns1" = Table.RenameColumns(#"Removed Columns",{{"Value.1", "Description"}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns1",{{"Date", type date}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type1","DATE ","",Replacer.ReplaceText,{"Type"})
in
    #"Replaced Value"[/SIZE]

now you can sort / filter / remove duplicates from description or whatever you want
 
Upvote 0
Thx Sandy for your answer.

If you remove duplicates, Descript28 is related to THING 1, when this must be in THING 2. Same thing with Descript55, must be with THING 3. How can I get the correct result? Blessings!
 
Upvote 0
you need to try yourself with columns selection and remove duplicates
I did unpivot as you wanted but the rest is up to you

remove duplicates from Description only is not mandatory :)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,376
Messages
6,119,174
Members
448,870
Latest member
max_pedreira

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