Forum Discussion
DagmaraG
3 years agoFrequent Visitor
Error in Date Field
Hi all!! I have a really strange case. My datasource is Google Sheet with many data (like 1 mln) for multiple dates. While loading it to Power BI I am geeting errors on Date fields. Why is ...
collinsg
3 years agoSolution Sage
Alignment to the left indicates the data is text. Alignment to the right indicates the data is numeric or datetime. The date of 8th October likely has spaces preceeding or following it which leaves it being interpreted as text. The following will convert all rows to datetime. It works by
- Testing the type of the raw date to see if it is datetime.
- If it is datetime then return the raw date.
- If it is not datetime assume it is text.
- Trim the text and
- Convert it to datetime.
= Table.AddColumn(
#"Name of Previous Step",
"Datetime", each
if ( Type.Is( Value.Type([Raw Date]), DateTime.Type) )
then [Raw Date]
else DateTime.From( Text.Trim([Raw Date]) ),
type datetime)
Here is my Google Sheet,
and here is my result in Power Query (I am working in UK local so my date format is day, month, year).