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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

Removing Text from a date column

I have a row that is meant to store the date when an item was launched. It is currently stored as a mix of just the date in format "1/10/19" or in the format "Launched-1/10/19" I want to remove everything but the date itself so the column can be changed into date format. I have tried using Text.Remove in the formula for a new column but I get an error that Text.Remove is not a function. Any help would be appreciated.

 

Thanks!

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

Try adding a custom column in the query editor with this formula.  It will only keep the numbers and / from your text.

 

= Text.Select([DateTextColumn], {"0".."9", "/"})

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

4 REPLIES 4
mahoneypat
Microsoft Employee
Microsoft Employee

Try adding a custom column in the query editor with this formula.  It will only keep the numbers and / from your text.

 

= Text.Select([DateTextColumn], {"0".."9", "/"})

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


az38
Community Champion
Community Champion

Hi @Anonymous 

Execute Split Column by Delimiter "-" in Power Query Editor mode (Transform ribbon)


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

I apologize I should have been more specific in my question, some are formatted "Launched-1/2/20" some are "Launched 1/2/20" some are "soft transition 1/2/20" and some are just "1/2/20". How would I get all of the dates in one column using split by delimiter.

Hey Nickpin,

 

    This might be a bit of a pain, but you might have to do a few delimiter splits and a custom column or two to get your data just right from the power query side. This is the play data I'm starting with

 

westwrightj_0-1594849463143.png

 

So what I'm going to do is actually split this by the common delimiter for the date which is "/"

 

 

    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Dates", type text}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Dates", Splitter.SplitTextByDelimiter("/", QuoteStyle.Csv), {"Dates.1", "Dates.2", "Dates.3"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Dates.1", type text}, {"Dates.2", Int64.Type}, {"Dates.3", Int64.Type}})
in
    #"Changed Type1"

 

 

That will give us this

 

 

westwrightj_1-1594849533024.png

 

Next we are going to create a custom column that pulls the numerical value out of the first field and add it with the other fields

 

 

= Table.AddColumn(#"Split Column by Delimiter", "Date", each Text.Select([Dates.1], {"0".."9"}) 
&
"/"
&
[Dates.2]
&
"/"
&
[Dates.3])

 

 

 

Which will give us this result

 

 

westwrightj_2-1594849655616.png

 

Go ahead and remove your old columns and change the data type to date and you should be set. 

 

westwrightj_3-1594849693972.png

 

Here are the steps from the advanced editor

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8kkszUvOSE3RNdQ30jcyUIrVQYgpIIkhMYPz00oUSooS84ozSzLz8+CqYgE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Dates = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Dates", type text}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Dates", Splitter.SplitTextByDelimiter("/", QuoteStyle.Csv), {"Dates.1", "Dates.2", "Dates.3"}),
    #"Added Custom" = Table.AddColumn(#"Split Column by Delimiter", "Date", each Text.Select([Dates.1], {"0".."9"}) 
&
"/"
&
[Dates.2]
&
"/"
&
[Dates.3]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Dates.1", "Dates.2", "Dates.3"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Removed Columns",{{"Date", type date}})
in
    #"Changed Type1"

 

 

 

 

 

 

 

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.