Power query question - dates into columns

Mendy32

New Member
Joined
Dec 23, 2019
Messages
36
Office Version
  1. 2019
Platform
  1. Windows
Hi,

I need help.!! how can I combine the names to one row but have all the dates in columns with the Level underneath the Dates...Can this be done power query?

I need to look like this for example

I.dNameDOBRAESEXADMIT3.9.2020 3.16.20203.25.2020etc...
6858Wonder Woman9/15/2000PINKMale2/16/2020H0H0H0H0
7848Superman8/31/1976WhiteMale6/4/2020H0H0H0H0


The list below is what I need combined...

I.d #NameDOBRAESEXADMITLevelDates
6858​
Wonder Woman
9/15/2000​
PINKMale
2/16/2020​
H03.9.2020
6858​
Wonder Woman
9/15/2000​
PINKMale
2/16/2020​
H03.16.2020
6858​
Wonder Woman
9/15/2000​
PINKMale
2/16/2020​
H03.25.2020
6858​
Wonder Woman
9/15/2000​
PINKMale
2/16/2020​
H04.1.2020
6858​
Wonder Woman
9/15/2000​
PINKMale
2/16/2020​
H04.8.2020
6858​
Wonder Woman
9/15/2000​
PINKMale
2/16/2020​
H04.15.2020
6858​
Wonder Woman
9/15/2000​
PINKMale
2/16/2020​
H04.22.2020
6858​
Wonder Woman
9/15/2000​
PINKMale
2/16/2020​
H04.29.2020
6858​
Wonder Woman
9/15/2000​
PINKMale
2/16/2020​
H05.6.2020
6858​
Wonder Woman
9/15/2000​
PINKMale
2/16/2020​
H05.20.2020
6858​
Wonder Woman
9/15/2000​
PINKMale
2/16/2020​
H05.27.2020
6858​
Wonder Woman
9/15/2000​
PINKMale
2/16/2020​
H06.3.2020
6858​
Wonder Woman
9/15/2000​
PINKMale
2/16/2020​
H06.10.2020
6858​
Wonder Woman
9/15/2000​
PINKMale
2/16/2020​
H06.17.2020
6858​
Wonder Woman
9/15/2000​
PINKMale
2/16/2020​
H06.24.2020
6858​
Wonder Woman
9/15/2000​
PINKMale
2/16/2020​
H07.1.2020
6858​
Wonder Woman
9/15/2000​
PINKMale
2/16/2020​
H07.8.2020
6858​
Wonder Woman
9/15/2000​
PINKMale
2/16/2020​
H05.13.2020
7848​
Superman
8/31/1976​
WhiteMale
3/6/2020​
H03.16.2020
7848​
Superman
8/31/1976​
WhiteMale
6/4/2020​
H06.10.2020
7848​
Superman
8/31/1976​
WhiteMale
6/4/2020​
H06.17.2020
7848​
Superman
8/31/1976​
WhiteMale
6/4/2020​
H06.24.2020
7848​
Superman
8/31/1976​
WhiteMale
6/4/2020​
H07.1.2020
7848​
Superman
8/31/1976​
WhiteMale
6/4/2020​
H07.8.2020
7848​
Superman
8/31/1976​
WhiteMale
6/4/2020​
H07.15.2020
7848​
Superman
8/31/1976​
WhiteMale
6/4/2020​
H07.22.2020
1587​
ROQUE
11/8/1993​
PINKFemale
2/25/2020​
H03.9.2020
6584​
BATMAN
3/20/1992​
ORANGEMale
10/4/2019​
H05.20.2020
6584​
BATMAN
3/20/1992​
ORANGEMale
10/4/2019​
H05.27.2020
6584​
BATMAN
3/20/1992​
ORANGEMale
10/4/2019​
H06.3.2020
6584​
BATMAN
3/20/1992​
ORANGEMale
10/4/2019​
H06.10.2020
6584​
BATMAN
3/20/1992​
ORANGEMale
10/4/2019​
H06.17.2020
6584​
BATMAN
3/20/1992​
ORANGEMale
10/4/2019​
H06.24.2020
6584​
BATMAN
3/20/1992​
ORANGEMale
10/4/2019​
H07.1.2020
6584​
BATMAN
3/20/1992​
ORANGEMale
10/4/2019​
H07.8.2020
6584​
BATMAN
3/20/1992​
ORANGEMale
10/4/2019​
H07.15.2020
6584​
BATMAN
3/20/1992​
ORANGEMale
10/4/2019​
H07.22.2020
6584​
BATMAN
3/20/1992​
ORANGEMale
10/4/2019​
H05.13.2020
749​
Aquaman
8/14/1994​
BrownMale
3/2/2020​
H03.9.2020
749​
Aquaman
8/14/1994​
BrownMale
3/2/2020​
H03.16.2020
749​
Aquaman
8/14/1994​
BrownMale
3/2/2020​
H03.25.2020
749​
Aquaman
8/14/1994​
BrownMale
3/2/2020​
H04.1.2020
749​
Aquaman
8/14/1994​
BrownMale
3/2/2020​
H04.8.2020
749​
Aquaman
8/14/1994​
BrownMale
3/2/2020​
H04.15.2020
83870​
FLASH
6/24/1992​
BrownMale
2/24/2020​
H03.9.2020
83870​
FLASH
6/24/1992​
BrownMale
2/24/2020​
H03.16.2020
83870​
FLASH
6/24/1992​
BrownMale
2/24/2020​
H07.8.2020
83870​
FLASH
6/24/1992​
BrownMale
2/24/2020​
H07.15.2020
83870​
FLASH
6/24/1992​
BrownMale
2/24/2020​
H07.22.2020
955882​
THOR
9/13/1985​
BrownMale
6/17/2020​
H06.24.2020
787667​
IRONMAN
1/2/1972​
WhiteMale
10/31/2019​
H05.20.2020
787667​
IRONMAN
1/2/1972​
WhiteMale
10/31/2019​
H05.27.2020
787667​
IRONMAN
1/2/1972​
WhiteMale
10/31/2019​
H06.3.2020
787667​
IRONMAN
1/2/1972​
WhiteMale
10/31/2019​
H06.10.2020
787667​
IRONMAN
1/2/1972​
WhiteMale
10/31/2019​
H06.17.2020
787667​
IRONMAN
1/2/1972​
WhiteMale
10/31/2019​
H06.24.2020
787667​
IRONMAN
1/2/1972​
WhiteMale
10/31/2019​
H07.1.2020
787667​
IRONMAN
1/2/1972​
WhiteMale
10/31/2019​
H07.8.2020
787667​
IRONMAN
1/2/1972​
WhiteMale
10/31/2019​
H07.15.2020
787667​
IRONMAN
1/2/1972​
WhiteMale
10/31/2019​
H07.22.2020
787667​
IRONMAN
1/2/1972​
WhiteMale
10/31/2019​
H05.13.2020
5917854​
PRINCE
4/4/1988​
WhiteMale
4/19/2020​
H14.22.2020
57421​
MICKEY MOUSE
2/5/1970​
PINKFemale
9/10/2019​
H14.15.2020
57421​
MICKEY MOUSE
2/5/1970​
PINKFemale
9/10/2019​
H14.22.2020
57421​
MICKEY MOUSE
2/5/1970​
PINKFemale
9/10/2019​
H14.29.2020
57421​
MICKEY MOUSE
2/5/1970​
PINKFemale
9/10/2019​
H15.6.2020
57421​
MICKEY MOUSE
2/5/1970​
PINKFemale
9/10/2019​
H15.20.2020
57421​
MICKEY MOUSE
2/5/1970​
PINKFemale
9/10/2019​
H15.27.2020
57421​
MICKEY MOUSE
2/5/1970​
PINKFemale
9/10/2019​
H16.3.2020
57421​
MICKEY MOUSE
2/5/1970​
PINKFemale
9/10/2019​
H16.10.2020
57421​
MICKEY MOUSE
2/5/1970​
PINKFemale
9/10/2019​
H16.17.2020
57421​
MICKEY MOUSE
2/5/1970​
PINKFemale
9/10/2019​
H16.24.2020
57421​
MICKEY MOUSE
2/5/1970​
PINKFemale
9/10/2019​
H17.1.2020
57421​
MICKEY MOUSE
2/5/1970​
PINKFemale
9/10/2019​
H17.8.2020
57421​
MICKEY MOUSE
2/5/1970​
PINKFemale
9/10/2019​
H15.13.2020
5896907​
LASSO
7/9/1993​
ORANGEMale
3/9/2020​
H03.16.2020
5896907​
LASSO
7/9/1993​
ORANGEMale
3/9/2020​
H03.25.2020
5896907​
LASSO
7/9/1993​
ORANGEMale
3/9/2020​
H04.1.2020
5896907​
LASSO
7/9/1993​
ORANGEMale
3/9/2020​
H04.8.2020
5896907​
LASSO
7/9/1993​
ORANGEMale
3/9/2020​
H04.15.2020
5896907​
LASSO
7/9/1993​
ORANGEMale
3/9/2020​
H04.22.2020
5896907​
LASSO
7/9/1993​
ORANGEMale
3/9/2020​
H04.29.2020
5896907​
LASSO
7/9/1993​
ORANGEMale
3/9/2020​
H05.6.2020
5896907​
LASSO
7/9/1993​
ORANGEMale
3/9/2020​
H05.20.2020
5896907​
LASSO
7/9/1993​
ORANGEMale
3/9/2020​
H05.27.2020
5896907​
LASSO
7/9/1993​
ORANGEMale
3/9/2020​
H06.3.2020
5896907​
LASSO
7/9/1993​
ORANGEMale
3/9/2020​
H06.10.2020
5896907​
LASSO
7/9/1993​
ORANGEMale
3/9/2020​
H06.17.2020
5896907​
LASSO
7/9/1993​
ORANGEMale
3/9/2020​
H06.24.2020
5896907​
LASSO
7/9/1993​
ORANGEMale
3/9/2020​
H07.1.2020
5896907​
LASSO
7/9/1993​
ORANGEMale
3/9/2020​
H07.8.2020
5896907​
LASSO
7/9/1993​
ORANGEMale
3/9/2020​
H07.15.2020
5896907​
LASSO
7/9/1993​
ORANGEMale
3/9/2020​
H07.22.2020
5896907​
LASSO
7/9/1993​
ORANGEMale
3/9/2020​
H05.13.2020
719​
CROWN
3/23/1993​
ORANGEMale
7/17/2020​
H17.22.2020
5731998​
RED BOOTS
9/13/1994​
PINKMale
8/30/2019​
H13.25.2020
5731998​
RED BOOTS
9/13/1994​
PINKMale
8/30/2019​
H14.1.2020
5731998​
RED BOOTS
9/13/1994​
PINKMale
8/30/2019​
H14.8.2020
5731998​
RED BOOTS
9/13/1994​
PINKMale
8/30/2019​
H14.15.2020
5731998​
RED BOOTS
9/13/1994​
PINKMale
8/30/2019​
H14.22.2020
5731998​
RED BOOTS
9/13/1994​
PINKMale
8/30/2019​
H14.29.2020
5731998​
RED BOOTS
9/13/1994​
PINKMale
8/30/2019​
H15.6.2020
5731998​
RED BOOTS
9/13/1994​
PINKMale
8/30/2019​
H15.20.2020
5731998​
RED BOOTS
9/13/1994​
PINKMale
8/30/2019​
H15.27.2020
5731998​
RED BOOTS
9/13/1994​
PINKMale
8/30/2019​
H16.3.2020
5731998​
RED BOOTS
9/13/1994​
PINKMale
8/30/2019​
H16.10.2020
5731998​
RED BOOTS
9/13/1994​
PINKMale
8/30/2019​
H16.17.2020
5731998​
RED BOOTS
9/13/1994​
PINKMale
8/30/2019​
H16.24.2020
5731998​
RED BOOTS
9/13/1994​
PINKMale
8/30/2019​
H17.1.2020
5731998​
RED BOOTS
9/13/1994​
PINKMale
8/30/2019​
H17.8.2020
5731998​
RED BOOTS
9/13/1994​
PINKMale
8/30/2019​
H17.15.2020
5731998​
RED BOOTS
9/13/1994​
PINKMale
8/30/2019​
H17.22.2020
5731998​
RED BOOTS
9/13/1994​
PINKMale
8/30/2019​
H15.13.2020
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
This works with exact data supplied. Hopefully can get you the rest of the way.
Paste in Advanced Editor, then fix Source in line 1 and "--Start Dates--"
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"I.d #", type text}, {"Name", type text}, {"DOB", type text}, {"RAE", type text}, {"SEX", type text}, {"ADMIT", type text}, {"Level", type text}, {"Dates", type date}}),
#"Removed Other Columns" = Table.SelectColumns(#"Changed Type",{"I.d #", "Name", "DOB", "RAE", "SEX", "ADMIT"}),
#"--End Unique IDs--" = Table.Distinct(#"Removed Other Columns"),
#"--Start Dates--" = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Removed Other Columns1" = Table.SelectColumns(#"--Start Dates--",{"I.d #", "Level", "Dates"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Removed Other Columns1",{{"Dates", type date}}),
#"--End Dates to Columns--" = Table.Pivot(Table.TransformColumnTypes(#"Changed Type1", {{"Dates", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Changed Type1", {{"Dates", type text}}, "en-US")[Dates]), "Dates", "Level"),
#"Merged Queries" = Table.NestedJoin(#"--End Unique IDs--", {"I.d #"}, #"--End Dates to Columns--", {"I.d #"}, "--End Dates to Columns--", JoinKind.LeftOuter),
#"Expanded --End Dates to Columns--" = Table.ExpandTableColumn(#"Merged Queries", "--End Dates to Columns--", {"I.d #", "3/9/2020", "3/16/2020", "3/25/2020", "4/1/2020", "4/8/2020", "4/15/2020", "4/22/2020", "4/29/2020", "5/6/2020", "5/20/2020", "5/27/2020", "6/3/2020", "6/10/2020", "6/17/2020", "6/24/2020", "7/1/2020", "7/8/2020", "5/13/2020", "7/15/2020", "7/22/2020"}, {"I.d #.1", "3/9/2020", "3/16/2020", "3/25/2020", "4/1/2020", "4/8/2020", "4/15/2020", "4/22/2020", "4/29/2020", "5/6/2020", "5/20/2020", "5/27/2020", "6/3/2020", "6/10/2020", "6/17/2020", "6/24/2020", "7/1/2020", "7/8/2020", "5/13/2020", "7/15/2020", "7/22/2020"}),
#"Removed Columns" = Table.RemoveColumns(#"Expanded --End Dates to Columns--",{"I.d #.1"})
in
#"Removed Columns"
 
Upvote 0
I'm trying and I keep giving me an error...can you send it and example on how it will look

thanks
 
Upvote 0
I'm trying and I keep giving me an error...can you send it and example on how it will look

thanks
in Power Query Editor from Applied Steps remove all steps like: #"Changed Type" (luckily only two :giggle: )
 
Upvote 0
I'm still having issues...I get Syntax Error: invalid identifier
 
Upvote 0
I changed whole M and got this
I.d #NameDOBRAESEXADMIT09/03/202016/03/202025/03/202001/04/202008/04/202015/04/202022/04/202029/04/202006/05/202020/05/202027/05/202003/06/202010/06/202017/06/202024/06/202001/07/202008/07/202013/05/202015/07/202022/07/2020
719CROWN23/03/1993ORANGEMale17/07/2020H1
749Aquaman14/08/1994BrownMale03/02/2020H0H0H0H0H0H0
1587ROQUE11/08/1993PINKFemale25/02/2020H0
6584BATMAN20/03/1992ORANGEMale10/04/2019H0H0H0H0H0H0H0H0H0H0H0
6858Wonder Woman15/09/2000PINKMale16/02/2020H0H0H0H0H0H0H0H0H0H0H0H0H0H0H0H0H0H0
7848Superman31/08/1976WhiteMale06/04/2020H0H0H0H0H0H0H0
7848Superman31/08/1976WhiteMale03/06/2020H0
57421MICKEY MOUSE02/05/1970PINKFemale09/10/2019H1H1H1H1H1H1H1H1H1H1H1H1H1
83870FLASH24/06/1992BrownMale24/02/2020H0H0H0H0H0
787667IRONMAN01/02/1972WhiteMale31/10/2019H0H0H0H0H0H0H0H0H0H0H0
955882THOR13/09/1985BrownMale17/06/2020H0
5731998RED BOOTS13/09/1994PINKMale30/08/2019H1H1H1H1H1H1H1H1H1H1H1H1H1H1H1H1H1H1
5896907LASSO07/09/1993ORANGEMale03/09/2020H0H0H0H0H0H0H0H0H0H0H0H0H0H0H0H0H0H0H0

Rich (BB code):
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Distinct = Table.Distinct(Source),
    TypeDOB = Table.TransformColumnTypes(Distinct, {{"DOB", type date}}, "en-US"),
    TypeAdmit = Table.TransformColumnTypes(TypeDOB, {{"ADMIT", type date}}, "en-US"),
    TypeDates = Table.TransformColumnTypes(TypeAdmit, {{"Dates", type date}}, "en-US"),
    Pivot = Table.Pivot(Table.TransformColumnTypes(TypeDates, {{"Dates", type text}}, "en-GB"), List.Distinct(Table.TransformColumnTypes(TypeDates, {{"Dates", type text}}, "en-GB")[Dates]), "Dates", "Level")
in
    Pivot
 
Upvote 0
I'm still having issues...I get Syntax Error: invalid identifier
probably you removed it manually from Advanced Editor
you should just click on X in front of the step eg.
rem.png
 
Upvote 0
or even shorter
Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    TypeDOB = Table.TransformColumnTypes(Source, {{"DOB", type date}}, "en-US"),
    TypeAdmit = Table.TransformColumnTypes(TypeDOB, {{"ADMIT", type date}}, "en-US"),
    TypeDates = Table.TransformColumnTypes(TypeAdmit, {{"Dates", type date}}, "en-US"),
    Pivot = Table.Pivot(Table.TransformColumnTypes(TypeDates, {{"Dates", type text}}), List.Distinct(Table.TransformColumnTypes(TypeDates, {{"Dates", type text}})[Dates]), "Dates", "Level")
in
    Pivot
the result is the same as above
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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