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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Convert a text column to a date column

Hello all,

I have an excel file that I am reporting on. I have a column where the majority of entries are a date, however there are a handful of entries in the workbook that state some sort of text phrase such as "empty" or something else. Is there a way to ignore these text values and still change the column to date format? Thanks.

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

How do you want to deal with the text phrases in this column? If you want to keep these text phrases as they are, the column could only be of Text data type. If you want to convert this column to Date data type, you will have errors for these text phrases and you could replace errors with null as @KNP has suggested. 

 

Below is an example. Also attached a .pbix file. 

21101501.jpg

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

KNP
Super User
Super User

Hi @Anonymous,

 

Are you receiving an error currently when trying to convert to a date?

 

You could try this and see if it works.

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText(
          "i45WMjLQNzDVNzIwMlSK1QFyDfUNLBHc1NyCkkowy9BAH4ggErEA",
          BinaryEncoding.Base64
        ),
        Compression.Deflate
      )
    ),
    let
      _t = ((type nullable text) meta [Serialized.Text = true])
    in
      type table [date = _t]
  ),
  #"Changed Type" = Table.TransformColumnTypes(Source, {{"date", type date}}),
  #"Replaced Errors" = Table.ReplaceErrorValues(#"Changed Type", {{"date", null}})
in
  #"Replaced Errors"

 

PBIX file attached also.

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
xOIEmaj

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
image
fabric-SUbadge
Proud to be a Super User!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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