Forum Discussion
Error when sorting rows
- 9 months ago
Hi Anonymous I have loaded same formated data and solve this in a optimal way
here it is before the fix:
After Fixing:
Complete M-Code:
let Source = Table.FromRows( { {"1", "Mon 7/21/25", "Wed 7/23/25"}, {"2", "Thu 7/24/25", "Mon 7/28/25"} }, {"TaskID", "Start_Date", "Finish_Date"} ), CleanAndConvert = Table.TransformColumns( Source, { {"TaskID", each Number.FromText(_), Int64.Type}, {"Start_Date", each Date.FromText(Text.AfterDelimiter(_, " "), [Culture="en-US"]), type date}, {"Finish_Date", each Date.FromText(Text.AfterDelimiter(_, " "), [Culture="en-US"]), type date} } ), Sorted = Table.Sort(CleanAndConvert, {{"Start_Date", Order.Ascending}}) in SortedFind this helpful? ✔ Give a Kudo • Mark as Solution – help others too!
I’d love to stay connected. Join me on LinkedIn for more tips, learning paths, and real-world Fabric & Power BI solutions.
I already follow your advice but error still happen on Date column. Here's the one of error massage
DataFormat.Error: We couldn't parse the input provided as a Date value.
Details:
Thu 7/24/25
Your sample and error message explains things. What you need to do is add the culture (locale) argument to the very first step where you set the data types (usually the second step named #"Changed Type".
In the formula bar, the code will look something like:
= Table.TransformColumnTypes(Source,{{"Start_Date", type date}, {"End_Date", type date},{"Other Columns", type ...}})
You want to add the culture argument at the very end:
= Table.TransformColumnTypes(Source,{{"Start_Date", type date}, {"End_Date", type date},{"Other Columns", type ...}}, "en-US")
Note that the culture argument reflects the culture of the source date, not your computer date culture.
If errors remain after this, it is likely that the Weekday Name is incorrect for the date. You will need to recheck your source data to decide whether the Weekday Name is correct or the date itself is correct, and solve the problem a bit differently.