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

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Yes, it's been a while...I hope you are doing well.

Wait...I have a few dups..I need to group by Name and DOB..no need to include admit date
 
Upvote 0
I was too fast :)
try this
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"),
    Distinct = Table.Distinct(TypeDates, {"I.d #", "Name", "DOB", "RAE", "SEX", "ADMIT"}),
    Pivot = Table.Pivot(Table.TransformColumnTypes(Distinct, {{"Dates", type text}}), List.Distinct(Table.TransformColumnTypes(Distinct, {{"Dates", type text}})[Dates]), "Dates", "Level")
in
    Pivot
7848 looks like duplicate but in Admit you have different dates so this is not duplicate

if you don't care about ADMIT dates use:
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"),
    Distinct = Table.Distinct(TypeDates, {"I.d #", "Name", "DOB", "RAE", "SEX"}),
    Pivot = Table.Pivot(Table.TransformColumnTypes(Distinct, {{"Dates", type text}}), List.Distinct(Table.TransformColumnTypes(Distinct, {{"Dates", type text}})[Dates]), "Dates", "Level")
in
    Pivot
 
Last edited:
Upvote 0
or this one
Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Type = Table.TransformColumnTypes(Source,{{"DOB", type date}, {"ADMIT", type date}, {"Dates", type date}}, "en-US"),
    Distinct = Table.Distinct(Type, {"I.d #", "Name", "DOB", "RAE", "SEX"}),
    Pivot = Table.Pivot(Table.TransformColumnTypes(Distinct, {{"Dates", type text}}), List.Distinct(Table.TransformColumnTypes(Distinct, {{"Dates", type text}})[Dates]), "Dates", "Level")
in
    Pivot
 
Upvote 0
I keep getting this error message..:(


Expression.Error: The specified distinct criteria is invalid.
Details:
 
Upvote 0
Expression.Error: The specified distinct criteria is invalid.
Details:


  • = Table.Distinct(TypeDates, {"I.d #", "Name", "DOB", "RAE", "SEX", "ADMIT"})
 
Upvote 0
try
Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Type = Table.TransformColumnTypes(Source,{{"DOB", type date}, {"ADMIT", type date}, {"Dates", type date}}, "en-US"),
    Distinct = Table.Distinct(Type, {"I.d #"}),
    Pivot = Table.Pivot(Table.TransformColumnTypes(Distinct, {{"Dates", type text}}), List.Distinct(Table.TransformColumnTypes(Distinct, {{"Dates", type text}})[Dates]), "Dates", "Level")
in
    Pivot
 
Upvote 0
sure, hope you didn't change any headers in source table (PQ is case sensitive)
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,906
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