Culture and date parsing
Parse text using the source culture
Culture describes conventions for interpreting numbers and dates. For instance, a comma may be a grouping separator or a decimal separator. Parsing converts a string into a typed value; formatting converts a typed value into a presentation. A report viewer culture cannot correct an amount or date already parsed incorrectly. For mixed-source files keep an explicit culture per source or row and reject unknown conventions rather than falling back to the machine default.
Example 1: normalize two source formats
Paste this expression into a blank M query. Both rows are synthetic USD amounts; the culture tells us how to parse text, not which currency the amount represents. Dates use a known format for each source.
let Source = #table(type table [Code = text, Culture = text, AmountText = text, DateText = text, DateFormat = text], {{"0012", "en-US", "1,234.50", "03/04/2026", "MM/dd/yyyy"}, {"0120", "de-DE", "1.234,50", "04.03.2026", "dd.MM.yyyy"}}), Amounts = Table.AddColumn(Source, "AmountUSD", each Number.FromText([AmountText], [Culture]), Currency.Type), Dates = Table.AddColumn(Amounts, "BusinessDate", each Date.FromText([DateText], [Format = [DateFormat], Culture = [Culture]]), type date)in DatesExpected: both amounts equal 1234.50 USD; both dates are 2026-03-04. The total is 2469.00 USD. All source fields remain available for audit. These examples fit a four-decimal scale, and the dataset uses no exchange rate. For a single-source CSV, Change Type Using Locale is an alternative to writing M manually; inspect the generated step.
Example 2: convert an instant to the business calendar
A date alone is a calendar label; a timestamp with offset identifies an instant. Suppose a store reports using a fictional fixed UTC+04:00 offset, not a daylight-saving region. The following expression converts the same instant into that offset before extracting the business date.
let Instant = #datetimezone(2026, 3, 4, 21, 30, 0, 0, 0), Business = DateTimeZone.SwitchZone(Instant, 4), BusinessDate = DateTime.Date(DateTimeZone.RemoveZone(Business))in BusinessDateExpected: UTC 2026-03-04 21:30 corresponds to local 2026-03-05 01:30 +04:00, so the business date is 2026-03-05. Removing the zone first would leave the UTC clock reading and yield the wrong business date. Store an explicit UTC timestamp, offset or source zone metadata as needed before model load, because the model does not retain a datetimezone value. A fixed offset is not a named time zone with historical daylight-saving rules; a production conversion needs a separately verified rule set.
Common mistake: interpreting a calendar date as an instant
03/04/2026 can mean March 4 or April 3 depending on the format contract. An ambiguous string cannot be resolved reliably from its spelling alone. Use a documented source culture and format, preferably exchange dates as ISO year-month-day text. A business date such as 2026-03-04 in the original retail fixture is already date-only; do not shift it by four hours. For text timestamps without an offset, determine the source time zone before treating them as instants. A valid parse does not prove the source metadata is truthful.
Practice: normalize the edge fixture
In the second worksheet exercise, parse the two known-culture rows, identify the unknown-culture row without guessing, and compare the UTC date with the fixed-offset business date. Keep the raw text and both date interpretations in your audit notes.
Official reading
Number.FromText · Date.FromText · SwitchZone · RemoveZone · Culture. Documentation checked; native execution NOT RUN.