Power Query Date.From Function: Step-by-Step Guide
In this article
The Date.From function in Power Query converts a value—text, number, or datetime—into a date. It is the quickest way to standardize a column of mixed date formats so you can filter, group, or calculate with them. You do not need any special setup beyond Power Query, which is built into Excel and Power BI; just open the Power Query Editor and follow the steps below.
What You'll Need
- Excel (any modern version) or Power BI Desktop with Power Query available.
- A table or range of data that includes a column you want to convert to dates.
- Basic familiarity with the Power Query Editor interface.
Step-by-Step
- Load your data into Power Query. In Excel, select your table and go to Data > From Table/Range. In Power BI, use Home > Transform data to open the Power Query Editor. The exact menu labels can differ slightly by version or region.
- Select the column to convert. Click the column header that contains the date-like values (for example, a text column with entries like "2024-01-15" or "15/01/2024").
- Add a custom column (recommended for control). Go to Add Column > Custom Column. In the dialog, give the new column a name (e.g., "DateConverted"). In the formula box, type
Date.From([YourColumnName]), replacing[YourColumnName]with the actual name of your column (use the exact case and spacing). Click OK. - Alternatively, change the column type directly. With the column selected, go to the Home tab and click the data type icon (it may show "ABC" or "123") and choose Date. Power Query will attempt to convert the values using the same logic as Date.From. This is faster but less transparent; the custom column approach lets you keep the original data.
- Check for errors. After conversion, some cells may show "Error". Click the error cell to see the reason—usually the text is not in a recognizable date format, or it contains extra characters. You can filter out errors or clean the source data.
- Handle locale differences. If your text dates use a different order (e.g., day/month/year vs. month/day/year), Date.From may misinterpret them. Use
Date.FromText([Column], [Format="dd/MM/yyyy"])or specify a culture in the optional second argument:Date.From([Column], "en-GB"). The exact culture string depends on your data. - Apply and load. Once the new column looks correct, go to Home > Close & Load (Excel) or Home > Close & Apply (Power BI) to bring the cleaned data back into your workbook or model.
Common Mistakes
- Forgetting to reference the column correctly. In the Custom Column dialog, column names must be enclosed in square brackets and match exactly, including spaces and capitalization. A typo like instead of will cause an error.
- Assuming Date.From handles all text formats. It relies on the locale settings of your system. Text like "January 15, 2024" may convert fine in an English (US) locale but fail in others. Always verify a sample of results.
- Overwriting the original column. Changing the data type directly replaces the original values. If you need to keep the source, use a custom column instead.
- Ignoring errors. Errors left in the column can break downstream steps like filtering or merging. Address them before loading.
- Using Date.From on numbers without understanding the serial date system. A number like 45000 represents a date in Excel's serial system (starting from 1899-12-30). Date.From will convert it correctly, but if the number is not a valid serial date, you'll get an error.
Tips
- Use
Date.FromTextwhen you need to specify a format string or culture explicitly; it gives more control thanDate.Fromfor text inputs. - Preview the conversion on a small sample before applying to the whole column. You can use the first row filter or keep only a few rows temporarily.
- If your data contains time components and you only need the date,
Date.Fromwill drop the time portion automatically when converting a datetime value. - Combine with
try ... otherwiseto handle errors gracefully:try Date.From([Column]) otherwise nullwill replace errors with null, which you can then filter out. - Remember that Power Query is case-sensitive for column names in formulas, so double-check the exact name in the formula bar.
Troubleshooting
If the conversion does not work as expected, work through these checks in order:
- Error: "We couldn't convert to Date" – This usually means the text is not in a recognized date format. Inspect the original values for extra spaces, non-breaking spaces, or inconsistent separators. Use Power Query's Transform > Trim and Transform > Clean to remove them.
- Dates appear swapped (day/month vs. month/day) – The conversion uses your system's locale. If your data uses a different order, use
Date.FromTextwith a format string, e.g.,Date.FromText([Column], [Format="dd/MM/yyyy"]). Alternatively, provide a culture code as the second argument toDate.From. - Numbers convert to unexpected dates – Excel's serial date system starts at 1899-12-30. If your number is not a valid serial, you'll get an error. If you intended to treat the number as text, convert it to text first with
Text.From. - Column name not recognized – Ensure the column name in the formula exactly matches the header, including spaces. You can click the column name in the formula box to insert it automatically.
- Conversion works in preview but fails on refresh – This can happen if the data source changes format. Check that the source column still contains the same type of values. Consider adding error handling with
try ... otherwise. - Performance issues with large datasets –
Date.Fromis generally efficient, but if you have millions of rows, consider filtering to only the necessary rows before conversion, or use Table.TransformColumnTypes which can be faster for simple type changes.
Frequently Asked Questions
What is the difference between Date.From and Date.FromText?
Date.From is a general conversion function that accepts any value (text, number, datetime) and tries to produce a date. Date.FromText is specifically for text and lets you specify a format string and culture, giving you more control over parsing ambiguous formats.
Can Date.From handle null values?
Yes, if the input is null, Date.From returns null. It does not throw an error for nulls.
Why does Date.From return an error for some text dates?
The text may not match any date format recognized by your system's locale, or it may contain extra characters. Check for leading/trailing spaces, non-standard separators, or month names in a different language. Use Date.FromText with an explicit format to resolve.
Does Date.From work with datetime values?
Yes, it extracts the date portion and discards the time. For example, Date.From(#datetime(2024,1,15,14,30,0)) returns #date(2024,1,15).
How do I convert a column of dates stored as numbers (e.g., 45000) to actual dates?
Use Date.From([Column]). Power Query interprets the number as an Excel serial date (days since 1899-12-30). Ensure the number is a valid serial; otherwise, you'll get an error.
Can I use Date.From in a calculated column in Power BI?
Yes, but Power BI's DAX has its own date functions. Date.From is a Power Query (M) function used during data transformation, not in DAX. Use it in the Power Query Editor before loading data into the model.