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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Date columns

Hi all, I have a column with date values of the following format: 26-27 Jan, 44313, 25 Oct - 01 Nov and would like to convert this single column into 2 columns, start and end date like the below picture. Thanks in advance!

 

qnnn8_0-1706839327164.png

 

2 ACCEPTED SOLUTIONS
AngeloParana
Resolver I
Resolver I

First step is to address how data is recorded on the source.  If that's not an option.

 

On powerquery create an if else statement for each case (maybe length of character as reference of condition) 

 

Similar to this

if Text.Length([DateRangeColumn])=9 then .... transformation

else if Text.Length([DateRangeColumn])=5 then .....

else .....

 

View solution in original post

Anonymous
Not applicable

Hi @Anonymous ,

I agree with Angelo's insights and have refined the code based on them, please try it:
StartDate

let 
length = Text.Length([Column1]),
vday = Text.BeforeDelimiter([Column1],"-"),
vmonth = Text.AfterDelimiter([Column1]," "),
vdate =  Text.BeforeDelimiter([Column1],"-"),
result =
if length = 5 then Date.AddDays(#date(1899,12,30),Number.FromText([Column1])) 
else if length = 9 then Date.FromText(vday&vmonth)
else if length = 15 then Date.FromText(vdate)
else null 
in 
result

EndDate

let 
length = Text.Length([Column1]),
vday = Text.BetweenDelimiters([Column1],"-"," "),
vmonth = Text.AfterDelimiter([Column1]," "),
vdate =  Text.AfterDelimiter([Column1],"-"),
result =
if length = 5 then Date.AddDays(#date(1899,12,30),Number.FromText([Column1])) 
else if length = 9 then Date.FromText(vday&vmonth)
else if length = 15 then Date.FromText(vdate)
else null 
in 
result

vcgaomsft_0-1707114728599.png

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

I agree with Angelo's insights and have refined the code based on them, please try it:
StartDate

let 
length = Text.Length([Column1]),
vday = Text.BeforeDelimiter([Column1],"-"),
vmonth = Text.AfterDelimiter([Column1]," "),
vdate =  Text.BeforeDelimiter([Column1],"-"),
result =
if length = 5 then Date.AddDays(#date(1899,12,30),Number.FromText([Column1])) 
else if length = 9 then Date.FromText(vday&vmonth)
else if length = 15 then Date.FromText(vdate)
else null 
in 
result

EndDate

let 
length = Text.Length([Column1]),
vday = Text.BetweenDelimiters([Column1],"-"," "),
vmonth = Text.AfterDelimiter([Column1]," "),
vdate =  Text.AfterDelimiter([Column1],"-"),
result =
if length = 5 then Date.AddDays(#date(1899,12,30),Number.FromText([Column1])) 
else if length = 9 then Date.FromText(vday&vmonth)
else if length = 15 then Date.FromText(vdate)
else null 
in 
result

vcgaomsft_0-1707114728599.png

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum -- China Power BI User Group

AngeloParana
Resolver I
Resolver I

First step is to address how data is recorded on the source.  If that's not an option.

 

On powerquery create an if else statement for each case (maybe length of character as reference of condition) 

 

Similar to this

if Text.Length([DateRangeColumn])=9 then .... transformation

else if Text.Length([DateRangeColumn])=5 then .....

else .....

 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.