Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I encountered an error when sorting rows. I sorted two columns with Text and Whole Number types in ascending order. The column that caused the error was the one with the Date data type. I made sure that the date format was correct for each row by using “Using Locale,” but that didn't help. Thank you for your help.
Solved! Go to Solution.
Hi @Syauqi 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
Sorted
Find 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.
Hi @Syauqi,
Thank you for reaching out to Microsoft Fabric Community.
Thank you @Mauro89, @Royel and @ronrsnfld for the prompt response.
As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by the user's for the issue worked? or let us know if you need any further assistance.
Thanks and regards,
Anjan Kumar Chippa
Hi @Syauqi,
We wanted to kindly follow up to check if the solution provided by the user's for the issue worked? or let us know if you need any further assistance.
Thanks and regards,
Anjan Kumar Chippa
Hi @Syauqi 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
Sorted
Find 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.
Hi @Syauqi,
When sorting by a Date column in Power Query and you get an error, it usually means one of the values is not a true date type (even if it looks correct). This often happens when:
How to fix it:
Quick M-code example to enforce clean dates
= Table.TransformColumns(
Source,
{{"DateColumn", each try Date.From(_) otherwise null, type date}}
)
If the error persists, feel free to share:
Best regards!
PS: if you find this help
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.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 9 | |
| 8 | |
| 7 | |
| 6 |