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
RossC
Frequent Visitor

Date and time formatting

Hi I'm new here and trying to figure out DAX as I go, I have an issue with a Power BI Dashbard that I am trying to create from a downloaded report from an Old system, and I want to be able to refresh the data and let Power BI format the data for me. 

 

 

The report shows the date format as 20180424140009, I need to convert this number to

 

Year 2018,

Month 04 (April),

Day 24th

Hour 14:00

Min 00

Seconds 09

 

I have managed to do this in excel, but I don't really want to have to modify an excel file each time I want to refresh the report.  The Excel formula that works is below and only creates the date.  The time isn't required.

 

This formula only divides up the characters and then Power BI recognises them as a Date.

=TEXT(DATE(LEFT(L2,4),MID(L2,5,2),MID(L2,7,2))+TIME(MID(L2,9,2),MID(L2,11,2),MID(L2,13,2)),"dd/mm/yyyy")

 

Ideal output would be to conver this 20180424140009, to this 24/04/2018 as a Date Hierarchy

 

Thanks in advance for any help

 

Ross

 

 

1 ACCEPTED SOLUTION
themistoklis
Community Champion
Community Champion

@RossC

 

The DAX formula in PowerBi will be pretty much the same as the one in Excel.

 

Creata a new column and not measure and add the following code:

 

 

datenew = MID('Table'[DateColumn], 7,2) & "/" & MID('Table'[DateColumn], 5,2) & "/" & LEFT('Table'[DateColumn],4)

 

Then go to Modelling tab on top, select the datenew column and change the data type to Date

View solution in original post

2 REPLIES 2
themistoklis
Community Champion
Community Champion

@RossC

 

The DAX formula in PowerBi will be pretty much the same as the one in Excel.

 

Creata a new column and not measure and add the following code:

 

 

datenew = MID('Table'[DateColumn], 7,2) & "/" & MID('Table'[DateColumn], 5,2) & "/" & LEFT('Table'[DateColumn],4)

 

Then go to Modelling tab on top, select the datenew column and change the data type to Date

Thanks that worked perfectly!!! Smiley Very Happy

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.