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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Text won't turn to Date

Hi, 

 

I have tried converting my text to date by changing the Data Type formatting in the Column tools but just receive an error. See pic below. 

I also tried to create a column with the following code and received an error.

Date = FORMAT(LEFT(BOOJ30MF[MMDD],2) & RIGHT(BOOJ30MF[MMDD],2) & LEFT(BOOJ30MF[BOOJRSDT],4),"MM/DD/YYYY")
2020-08-19_14h05_28.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

I figured it out. I had to create an If statement to get rid of the 0s. Then I created another column with the following equation: 

 

Column 2 = Date(LEFT(BOOJ30MF[Requested date],4),MID(BOOJ30MF[Requested date],5,2) ,RIGHT(BOOJ30MF[Requested date],2))
 
2020-08-20_09h49_31.png

View solution in original post

20 REPLIES 20
mhossain
Solution Sage
Solution Sage

@Anonymous 

 

If you want to take DAX approach: You need to use Date function and mentione year, month day.

DATE(

RIGHT([DateText],4),

LEFT([BOOJ30MF[Date],2),

MID([DateTest],3,2))

 

You can do in powerquery too, using Date.FromText

 

Anonymous
Not applicable

Hi @Anonymous 

Use

FORMAT(table[col],"MMDDYYYY")

Anonymous
Not applicable

@ pranit828 - This still gives me an error 😕

Anonymous
Not applicable

Hi @Anonymous 

 

What is the data type of [date] column?

 

you can use the below function instead.

 

DATE(RIGHT(BOOJ30MF[Date],4),LEFT(BOOJ30MF[Date],2),MID(BOOJ30MF[Date],3,2))

 

HI @Anonymous .

 

Try this formula:

 

Date = Date(LEFT(BOOJ30MF[BOOJRSDT],4),LEFT(BOOJ30MF[MMDD],2) ,RIGHT(BOOJ30MF[MMDD],2))

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

Hi @MFelix , 

 

I am receiving the error "An argument of the function 'DATE' has the wrong data type or the result is too large or too small."

Hi @Anonymous ,

 

I have test it out and everything is working correcty can you confirm the formula you are using please.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

@MFelix @Anonymous 

 

Using the Date function isn't working. 2020-08-19_14h50_23.png

Anonymous
Not applicable

HI @Anonymous 

 

One or both columns from which you are pulling the year, month and date is of text type.

Convert it to number and use the same formulate as in your screen shot

 

or use,

 

DATE(FORMAT(LEFT(BOOJ30MF[Date],4),"####"),FORMAT(LEFT(BOOJ30MF[MMDD],2),"##"),FORMAT(RIGHT(BOOJ30MF[MMDD],2),"##"))

 

 

Anonymous
Not applicable

@Anonymous 

 

Still receiving2020-08-19_15h07_43.png the error 😕

 

 

Anonymous
Not applicable

Hi @Anonymous 

 

Did you change the data type of both columns to number? looks like it is still text.

Also, Create this as a measure.

 

Anonymous
Not applicable

@Anonymous 

 

Ok I changed both columns to "whole number" then tried to create the measure but it won't find the columns I am trying to pull in.

2020-08-19_15h40_09.png

Anonymous
Not applicable

Hi @Anonymous ,

That's because you're creating a measure, please create a calculated column with below formula(just keep the data type of column BOOJRSDT and MMDD as Text) and set the date format for it in Column Tools ribbon.

Column = DATE(LEFT('BOOJ30MF'[BOOJRSDT],4),LEFT('BOOJ30MF'[MMDD],2),RIGHT('BOOJ30MF'[MMDD],2))

Text won't turn to Date.JPG

Best Regards

Rena

Anonymous
Not applicable

@Anonymous 

I did that and it still is giving me and error

2020-08-20_08h47_08.png

Anonymous
Not applicable

I think there is an issue because the date field I am pulling in is coming from a database. I am trying to find a workaround but have been unsuccessful with everything I try. 

Anonymous
Not applicable

I figured it out. I had to create an If statement to get rid of the 0s. Then I created another column with the following equation: 

 

Column 2 = Date(LEFT(BOOJ30MF[Requested date],4),MID(BOOJ30MF[Requested date],5,2) ,RIGHT(BOOJ30MF[Requested date],2))
 
2020-08-20_09h49_31.png
MFelix
Super User
Super User

Hi @Anonymous 

 

That type of information will not give you a date format you need to do the following:

 

Date = LEFT(BOOJ30MF[MMDD],2) &"/&RIGHT(BOOJ30MF[MMDD],2) & "/" & LEFT(BOOJ30MF[BOOJRSDT],4)

 

And then format the column as a date column.

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

@ MFelix - I am getting the error "Cannot convert value "0/0/0" of type Text to type Date

Hi @Anonymous ,

 

Power BI doesn't recognise MMDDYYYY directly as a Date format. That's why you are not able to directly convert into date field.

Same is the issue when you use FORMAT function

 

Create a calculated column by splitting and joining existing column to have data in the format of a date(MM/DD/YYYY or DD/MM/YYYY or any other Date format).

Probably this new column will be of text data type but in Power BI recognizable date format, hence you will just need to convert this date data type.

 

Give a thumbs up if this post helped you in any way and mark this post as solution if it solved your query !!!

 
Anonymous
Not applicable

@Anand24 

 

I did that but it still is formated as text even though it looks like a date. 2020-08-19_14h38_22.png

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.