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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Change whole number to date

I have excel files that always display the date as 5312021. I want to change this to an actual date format. The other articles I've read have not worked for me. Any help is appreciated. I'm still learning how this all works. Example below.

ldirks_0-1624573063735.png

 

 

2 ACCEPTED SOLUTIONS

@Anonymous 

pls try this

Column = if(len('Table (4)'[date])=7,date(right('Table (4)'[date],4),left('Table (4)'[date],1),mid('Table (4)'[date],2,2)),date(right('Table (4)'[date],4),left('Table (4)'[date],2),mid('Table (4)'[date],3,2)))

1.PNG





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

Proud to be a Super User!




View solution in original post

FrankAT
Community Champion
Community Champion

Hi @Anonymous ,

use the following formula for a calculated column:

 

27-06-_2021_00-28-23.png

 

 

Date = 
DATE(
    RIGHT('Table'[ORDER_DATE],4), 
    LEFT(RIGHT('Table'[ORDER_DATE],6),2), 
    LEFT('Table'[ORDER_DATE], LEN('Table'[ORDER_DATE]) - 6)
)

 

With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)

View solution in original post

6 REPLIES 6
FrankAT
Community Champion
Community Champion

Hi @Anonymous ,

use the following formula for a calculated column:

 

27-06-_2021_00-28-23.png

 

 

Date = 
DATE(
    RIGHT('Table'[ORDER_DATE],4), 
    LEFT(RIGHT('Table'[ORDER_DATE],6),2), 
    LEFT('Table'[ORDER_DATE], LEN('Table'[ORDER_DATE]) - 6)
)

 

With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)

mahoneypat
Employee
Employee

What happens when the day is <10?  Do you see 522021 or 5022021, for example?  And if the month is >9?  Do you see 1122021 or 11022021?

 

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


Anonymous
Not applicable

It displays 2 digits for the day on all dates 5022021. Will display 1 or 2 digit month.

@Anonymous 

pls try this

Column = if(len('Table (4)'[date])=7,date(right('Table (4)'[date],4),left('Table (4)'[date],1),mid('Table (4)'[date],2,2)),date(right('Table (4)'[date],4),left('Table (4)'[date],2),mid('Table (4)'[date],3,2)))

1.PNG





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

Proud to be a Super User!




Anonymous
Not applicable

I tried this and I got the following error.

 

ldirks_0-1624993197447.png

 

@Anonymous 

not create a column in PQ, use DAX to create a column

1.PNG





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

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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