Extracting Dates from Irregular Strings in Power Query
Short answer
D Use Create Column from Examples to let Power Query intelligently parse the 'YYYY-MM-DD at HH:MM' string into a native Date type suitable for hierarchies.
Question
You need to be able to analyze the complaints by the logged date and use a built-in date hierarchy.
What should you do?
Key Takeaways
The trap is trying manual text manipulation; the key insight is that Power Query's AI-driven examples can parse and type-cast complex strings in one step.
Learn how to handle irregular date formats like '2018-12-31 at 08:59' using Create Column from Examples to ensure compatibility with Power BI date hierarchies.
Common mistake: Splitting by delimiter (B) often leaves whitespace or partial data that requires additional manual cleaning and type casting steps, making it less efficient than examples.
Expert Analysis
The Logged column contains a non-standard date format: '2018-12-31 at 08:59'. To use the built-in date hierarchy in Power BI, the column must be of Date or DateTime data type. The goal is to extract just the date portion (YYYY-MM-DD) and convert it.
Option C suggests extracting the last 11 characters ('12-31 at 08:59' is 14 chars, so this logic is flawed if applied blindly, but let's look closer). Actually, '2018-12-31' is 10 characters. The string is '2018-12-31 at 08:59'. Extracting the first 10 characters would give '2018-12-31'. Option C says 'last 11 characters', which would result in '-31 at 08:59' or similar, which cannot be parsed as a standard date easily without complex cleaning. Wait, let's re-read carefully. The format is 'YYYY-MM-DD at HH:MM'. Length is 19. Last 11 chars: 't 08:59'? No. 'at 08:59' is 8 chars. ' at 08:59' is 9. '31 at 08:59' is 12. This option seems technically incorrect for extraction.
Let's look at Option D: Create a column by example. Power Query's 'Column from Examples' feature is intelligent. If you provide an input like '2018-12-31 at 08:59' and want the output '2018-12-31', Power Query will automatically detect that you want to split on ' at ' and take the left part, then set the data type to Date. It handles the formatting and type conversion implicitly. This is the most robust and user-friendly method for irregular formats.
Option A creates a conditional column for years only, losing the month and day, so no date hierarchy. Option B splits by 'at', leaving spaces and potentially time parts, requiring further steps to clean and cast.
Therefore, creating a column by example (D) is the best practice because it allows Power Query to infer the pattern and perform the necessary parsing and typing automatically, ensuring the result is a valid Date type compatible with hierarchies.
Exam Strategy
When dealing with messy data types, prioritize 'From Examples' features first. They reduce error-prone manual coding. Always verify the final column type matches the requirement (Date vs Text) before building hierarchies.
Frequently Asked Questions
Why not just change the data type directly?
Does Column from Examples always work?
Community Votes
100% of anonymous learners picked answer D. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 1 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 1
-
ds_6852 👍 1 Answered DUsing "at" as a delimiter leaves spaces in the split columns. D would be a better way to ensure the outcome column is a date.
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.
Related Analysis
Practice All PL-300 Questions
Access 116 questions with complete answers and detailed explanations.
View Full PL-300 Practice Test →