I’m sure as an analyst, you may have once been faced with the challenge of some data with a date field in the format ‘YYYYMMDD’ (e.g., 20240306) and want to transform it to a proper date format (e.g., 06–03–2024).
In this tutorial, I will show you how to change yyyymmdd to date format in Power BI using DAX and Power Query Editor.
How to Change yyyymmdd to Date Format in Power BI [Using DAX]
Now, I will tell you how to convert yyyymmdd to date in Power BI using DAX.
Scenario:
Let’s say you work for a logistics company that tracks package delivery dates using a format like “yyyymmdd” (e.g., 20240310 for March 10th, 2024). You want to convert these dates into a standard format to analyze delivery trends easily.
According to this scenario, we have an Excel file named Delivery Data with columns Delivery Date. Check the screenshot below.
Now we see how to convert. Follow the below steps:
1. Open Power BI Desktop and load data using the Get data option. Then, you can see data in the Data pane.
2. Now Go to Table view -> Under the “Table tools” tab, click New column.
3. In the formula bar, put the below DAX expression. Then click the Commit button.
DeliveryDate = DATE(VALUE(LEFT('DeliveryData'[Delivery Date],4)), VALUE(MID('DeliveryData'[Delivery Date],5,2)), VALUE(RIGHT('DeliveryData'[Delivery Date],2)))
Where:
- DeliveryDate = This is the name we’re giving to the new column that will contain the date format.
- DATE = This function in DAX constructs a date value from the year, month, and day components.
- VALUE(LEFT(‘DeliveryData'[Delivery Date],4)) = This part extracts the leftmost 4 characters (representing the year) from the “Delivery Date” column in the “DeliveryData” table and converts them into a numeric value.
- VALUE(MID(‘DeliveryData'[Delivery Date],5,2)) = This section extracts the characters starting from the 5th position up to 2 characters long (representing the month) from the “Delivery Date” column and converts them into a numeric value.
- VALUE(RIGHT(‘DeliveryData'[Delivery Date],2)) = Here, it takes the rightmost 2 characters (representing the day) from the “Delivery Date” column and converts them into a numeric value.
4. You see the DeliveryDate created in the Table view.
This way, we can use DAX to convert “yyyymmdd” dates to a standard date format in Power BI. This lets you analyze delivery trends and make data-driven decisions to improve logistics operations.
Power Query Convert yyyymmdd to Date
This example shows how to convert yyyymmdd to date in Power Query Editor.
1. Under the Home tab, click Transform data.
2. Select the column -> Under the Transform, expand Data Type: Whole Number. Check the screenshot below.
3. Then, in the dialog box, click Text. If you can click Date/Time, it gives you an error.
4. Click the Add new step in the Change Column Type dialog box.
5. Then, under the Transform tab, expand Data Type: Text -> click Date.
6. Click the Add new step in the Change Column Type dialog box.
7. Now you can see we successfully converted the standard date format in Power Query Editor.
This tutorial taught us how to convert yyyymmdd to date in Power BI using DAX and change the date format yyyymmdd to date in Power Query Editor.
Additionally, you may like some more Power BI articles:
- Convert Hours to Minutes in Power BI
- Convert Date to Text in Power BI
- Convert Number to Text in Power BI
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com