Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
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!
Solved! Go to Solution.
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 .....
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
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
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
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
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 .....
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 3 | |
| 3 | |
| 2 |