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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Warren10976
Regular Visitor

Copy values from one column to another

I have a column containg text and date in power query, how do I copy text values only to new column and date values only to another column. I need this information to be in seperate columns. Thank you for your help.

Warren10976_1-1654765940213.png

 

1 ACCEPTED SOLUTION

You should copy the formula as it is rather than writing.

You put one comma after null and also ommitted try part. Copy and paste the below formula

= try if Value.Is(DateTime.From([Opened]), type datetime) then null else [Opened] otherwise [Opened]

View solution in original post

4 REPLIES 4
Warren10976
Regular Visitor

Thank You so much it worked

Vijay_A_Verma
Super User
Super User

Use below formulas assuming your column name is Data

for date part
= try Date.From(DateTime.From([Data])) otherwise null
for text part
= try if Value.Is(DateTime.From([Data]), type datetime) then null else [Data] otherwise [Data]

 See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSkxK1lGoqKxSitWJVjLTt9Q3MjAyUjA0sjIytTK1VAjwBUuY6hvBZKzMrQxNFRwh4mDC0MjYpKikUik2FgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Data = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Date Part", each try Date.From(DateTime.From([Data])) otherwise null, type date),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Text Part", each try if Value.Is(DateTime.From([Data]), type datetime) then null else [Data] otherwise [Data], type text)
in
    #"Added Custom1"

Thank you so much for the solution, 

  • The date part worked like a charm (
    Date.From(DateTime.From([Data])) otherwise null​
  • The text part is not working, See below 
  • Warren10976_0-1655806306647.png

    Your assitance is much appreciated.

You should copy the formula as it is rather than writing.

You put one comma after null and also ommitted try part. Copy and paste the below formula

= try if Value.Is(DateTime.From([Opened]), type datetime) then null else [Opened] otherwise [Opened]

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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