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.
Hello. I have a set of excel files which I compile in Access in order to analyse them. After append the 5 files into a access table, I import to Power Query in order to manipulate them.
The problem is the data format, it's not the same in the 5 files. One of the errors is in a Date Column. This date column is in text format but when I convert to date/time format, I have a lot of errors. In the Date Column, I have fields with date and time, only time and these kind of stuff:
Date_Column
2020-06-19 17:27:51.130000000
First: I want to convert all of these rows that have 2020-06-19 17:27:51.130000000 format to 2020-06-19 17:27:51. So, remove the numbers after the dot.
Second: Convert all entries into Date/time format even with the only date entries.
Anyone can help me?
Thank you!
Solved! Go to Solution.
Hi @Anonymous, let me see if I understand. You are using this formula:
= DateTime.Date(DateTime.FromText([YourColumnHere], "pt-PT"))
But your issue is the hours/min/sec are all zeros even if they exist.
If I have that right, here is why.
You could trap this with something like this in a new Custom Column:
let
varDateTime = DateTime.FromText([DataEncomenda], "pt-PT"),
varDate = DateTime.Date(varDateTime)
in
if varDateTime = DateTime.From(varDate)
then varDate
else varDateTime
It returns this from your sample data that I tweaked on the first two rows. I used variables above because I didn't want to type those functions in a dozen times.
What my formula did is:
I keep varDateTime if there are valid times, and keep varDate if there are none or the times are all zeros.
Make sense?
Also note that If I then format that final column as DateTime, PQ will put the zero times back in. It essentially does a DateTime.From() on the entire column.
DAX is for Analysis. Power Query is for Data Modeling
Proud to be a Super User!
MCSA: BI ReportingCovering 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.