Microsoft Certified: Power BI Data Analyst AssociatePrepare the dataMedium

A data analyst is working with a sales dataset in Power Query. The 'SalesDate' column is currently stored as text and contains values in various formats such as '2023-01-15', '1/2/2023', and 'Jan 5, 2023'. The analyst needs to convert this column to a proper 'Date' data type to enable date-based filtering and calculations. Which Power Query operation is the most robust way to handle these mixed date formats during conversion?

  1. AAdd a Custom Column using `Date.FromText()` with a format specifier for each known format.
  2. BSplit the column by delimiter, then combine parts to form a standardized date string, then change type.
  3. CChange Type Using Locale, selecting a locale that generally handles multiple common date formats.
  4. DChange Type to Date, allowing Power Query to infer the format.
Show answer & explanation

Correct answer: C. Change Type Using Locale, selecting a locale that generally handles multiple common date formats.

Changing type using locale is the most robust approach for handling mixed date formats because it leverages the locale's intelligence to parse various common date representations, often succeeding where a simple 'Change Type' might fail or produce errors for non-standard formats.

Why the other options are wrong

  • A. This approach would be overly complex and fragile, requiring knowledge of all possible formats and creating a lengthy M formula, which is difficult to maintain for varied data.
  • B. Splitting and recombining is generally inefficient and prone to errors when dealing with varied date formats, as the position of day, month, and year can change.
  • D. A simple 'Change Type' might fail or incorrectly parse dates that do not conform to a single, default recognized format, leading to errors.

Change Type Using Locale (Power Query)

A Power Query transformation that converts a column's data type while considering cultural formatting rules. This is particularly useful for parsing dates, times, and numbers that vary by region.

  • Handles varied date, time, and number formats.
  • Leverages cultural settings for parsing.
  • Accessed via 'Using Locale...' option in Change Type menu.

Memory trick: Dates are global travelers; locales help them fit in anywhere.

More Prepare the data questions