Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Combine Date Columns and create a phase column

Hi,

 

At the moment, I have data that looks like this :

Project TitleInitiation Start DateInitiation End DateDesign Start DateDesign End Date
Project 12020-01-012020-05-012020-07-012020-12-01
Project 22022-01-012022-03-012022-08-012023-01-01
Project 32021-02-012021-06-012021-10-01

2022-03-01

 

I want to have only one start date and end date column and create a new column which identifies the phase. Anyone knows how to get this transformation done?

Project TitlePhaseStart DateEnd Date
Project 1Initiation2020-01-012020-05-01
Project 1Design2020-07-012020-12-01
Project 2Initiation2022-01-012022-03-01
Project 2Design2022-08-012023-01-01
Project 3Initiation2021-02-012021-06-01
Project 3Design2021-10-012022-03-01
1 ACCEPTED SOLUTION
Arul
Super User
Super User

@Anonymous ,

You can do. Please follow the below steps,

Step 1 : Duplicate the source table and remove the "Initiation Start Date", "Initiation End Date" columns from the duplicated table. Your duplicated table should look like the below after removal of the above mentioned columns.

Arul_0-1670521942542.png

Step 2: Remove the "Design Start Date", "Design End Date" from the source table and then append the duplicate table to the source table. It should look like the below,

Arul_1-1670522241139.png

and then follow the attached Power query code from Unpivoted Other Columns step , you will get the result.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCijKz0pNLlEwVNJRMjIwMtA1MAQiOMcUmWOOxDE0AnFidRAmGEGkjJBNAHKMkTkWcI4xVBmyCcYQKaC4EVwdkGOGxDE0wDA7NhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Project Title" = _t, #"Initiation Start Date" = _t, #"Initiation End Date" = _t, #"Design Start Date" = _t, #"Design End Date" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Project Title", type text}, {"Initiation Start Date", type date}, {"Initiation End Date", type date}, {"Design Start Date", type date}, {"Design End Date", type date}}),
    #"Removed Columns1" = Table.RemoveColumns(#"Changed Type",{"Design Start Date", "Design End Date"}),
    #"Appended Query" = Table.Combine({#"Removed Columns1", #"Duplicate of Sample Table to append"}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Appended Query", {"Project Title"}, "Attribute", "Value"),
    #"Added Conditional Column" = Table.AddColumn(#"Unpivoted Other Columns", "Start Date", each if [Attribute] = "Initiation Start Date" then [Value] else if [Attribute] = "Design Start Date" then [Value] else null),
    #"Added Conditional Column1" = Table.AddColumn(#"Added Conditional Column", "End Date", each if [Attribute] = "Initiation End Date" then [Value] else if [Attribute] = "Design End Date" then [Value] else null),
    #"Removed Columns" = Table.RemoveColumns(#"Added Conditional Column1",{"Value"}),
    #"Filled Up" = Table.FillUp(#"Removed Columns",{"End Date"}),
    #"Removed Alternate Rows" = Table.AlternateRows(#"Filled Up",1,1,1),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Alternate Rows",{{"Attribute", "Phase"}}),
    #"Replaced Value" = Table.ReplaceValue(#"Renamed Columns","Start Date","",Replacer.ReplaceText,{"Phase"}),
    #"Sorted Rows" = Table.Sort(#"Replaced Value",{{"Project Title", Order.Ascending}})
in
    #"Sorted Rows"

 

 

Thanks,





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


LinkedIn


View solution in original post

1 REPLY 1
Arul
Super User
Super User

@Anonymous ,

You can do. Please follow the below steps,

Step 1 : Duplicate the source table and remove the "Initiation Start Date", "Initiation End Date" columns from the duplicated table. Your duplicated table should look like the below after removal of the above mentioned columns.

Arul_0-1670521942542.png

Step 2: Remove the "Design Start Date", "Design End Date" from the source table and then append the duplicate table to the source table. It should look like the below,

Arul_1-1670522241139.png

and then follow the attached Power query code from Unpivoted Other Columns step , you will get the result.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCijKz0pNLlEwVNJRMjIwMtA1MAQiOMcUmWOOxDE0AnFidRAmGEGkjJBNAHKMkTkWcI4xVBmyCcYQKaC4EVwdkGOGxDE0wDA7NhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Project Title" = _t, #"Initiation Start Date" = _t, #"Initiation End Date" = _t, #"Design Start Date" = _t, #"Design End Date" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Project Title", type text}, {"Initiation Start Date", type date}, {"Initiation End Date", type date}, {"Design Start Date", type date}, {"Design End Date", type date}}),
    #"Removed Columns1" = Table.RemoveColumns(#"Changed Type",{"Design Start Date", "Design End Date"}),
    #"Appended Query" = Table.Combine({#"Removed Columns1", #"Duplicate of Sample Table to append"}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Appended Query", {"Project Title"}, "Attribute", "Value"),
    #"Added Conditional Column" = Table.AddColumn(#"Unpivoted Other Columns", "Start Date", each if [Attribute] = "Initiation Start Date" then [Value] else if [Attribute] = "Design Start Date" then [Value] else null),
    #"Added Conditional Column1" = Table.AddColumn(#"Added Conditional Column", "End Date", each if [Attribute] = "Initiation End Date" then [Value] else if [Attribute] = "Design End Date" then [Value] else null),
    #"Removed Columns" = Table.RemoveColumns(#"Added Conditional Column1",{"Value"}),
    #"Filled Up" = Table.FillUp(#"Removed Columns",{"End Date"}),
    #"Removed Alternate Rows" = Table.AlternateRows(#"Filled Up",1,1,1),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Alternate Rows",{{"Attribute", "Phase"}}),
    #"Replaced Value" = Table.ReplaceValue(#"Renamed Columns","Start Date","",Replacer.ReplaceText,{"Phase"}),
    #"Sorted Rows" = Table.Sort(#"Replaced Value",{{"Project Title", Order.Ascending}})
in
    #"Sorted Rows"

 

 

Thanks,





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


LinkedIn


Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors