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.
Hi,
The excel file extracted from system has inconsistent date format.
If import to Power BI directly, Power BI will read those with "/" (eg. 8/31/2020) as MDY and those with "-" (eg. 08-11-20) as DMY.
Actually all should be read as MDY.
How can I solve this issue?
Solved! Go to Solution.
Hi @PBI_newuser ,
Please update the formula of calculated column [Formatted Date] as below:
Formatted Date =
IF (
IFERROR ( FIND ( "-", 'Sample'[Complete Date] ), 0 ) > 0,
DATE ( CONCATENATE ( "20", RIGHT ( 'Sample'[Complete Date], 2 ) ), SWITCH (
MID ( 'Sample'[Complete Date], 4, 3 ),
"Jan", "1",
"Feb", "2",
"Mar", "3",
"Apr", "4",
"May", "5",
"Jun", "6",
"Jul", "7",
"Aug", "8",
"Sep", "9",
"Oct", "10",
"Nov", "11",
"Dec", "12"
), LEFT ( 'Sample'[Complete Date], 2 ) ),
DATEVALUE ( 'Sample'[Complete Date] )
)
Best Regards
Rena
Community Support Team _ Rena Ruan
If this post helps, then please consider Accept it as the solution to help the other members find it more.
In Power Query, select the column, select "Replace values" in the ribbon and swap the "-" for a "/"
Proud to be a Super User!
Paul on Linkedin.
Hi @PBI_newuser ,
Assue that the date field looks like the ones in the below screenshot, you can create a calculated column to format the date field. Then set the proper date format for it.
Formatted date = IF (
IFERROR ( FIND ( "-", 'Table'[Paperwork Complete Date] ), 0 ) > 0,
DATE ( CONCATENATE ( "20", RIGHT ( 'Table'[Paperwork Complete Date], 2 ) ), MID ( 'Table'[Paperwork Complete Date], 4, 2 ), LEFT ( 'Table'[Paperwork Complete Date], 2 ) ),
IF (
IFERROR ( FIND ( "/", 'Table'[Paperwork Complete Date] ), 0 ) > 0,
DATE ( RIGHT ( 'Table'[Paperwork Complete Date], 4 ), MID ( 'Table'[Paperwork Complete Date], 3, 2 ), LEFT (
'Table'[Paperwork Complete Date],
IFERROR ( FIND ( "/", 'Table'[Paperwork Complete Date] ), 0 ) - 1
) )
)
)
Best Regards
Rena
Community Support Team _ Rena Ruan
If this post helps, then please consider Accept it as the solution to help the other members find it more.
Hi @v-yiruan-msft ,
I follow your steps but I got the below error.
"Cannot convert value 'Ja' of type Text to type Integer.
After importing the excel file to Power BI, the data appeared to be as below.
Sample pbix:
Hi @PBI_newuser ,
Please update the formula of calculated column [Formatted Date] as below:
Formatted Date =
IF (
IFERROR ( FIND ( "-", 'Sample'[Complete Date] ), 0 ) > 0,
DATE ( CONCATENATE ( "20", RIGHT ( 'Sample'[Complete Date], 2 ) ), SWITCH (
MID ( 'Sample'[Complete Date], 4, 3 ),
"Jan", "1",
"Feb", "2",
"Mar", "3",
"Apr", "4",
"May", "5",
"Jun", "6",
"Jul", "7",
"Aug", "8",
"Sep", "9",
"Oct", "10",
"Nov", "11",
"Dec", "12"
), LEFT ( 'Sample'[Complete Date], 2 ) ),
DATEVALUE ( 'Sample'[Complete Date] )
)
Best Regards
Rena
Community Support Team _ Rena Ruan
If this post helps, then please consider Accept it as the solution to help the other members find it more.
@PBI_newuser Similar scenerios have been handled here-
https://community.powerbi.com/t5/Power-Query/Inconsistent-date-format-in-source-data/m-p/1078746
Please check.
Appreciate your kudos!! Mark this post as solution if this helps.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
99 | |
82 | |
70 | |
60 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |