Power Query uses AI heuristics to infer transformations from examples. This exercise follows the product documentation.[6][1]
In Excel for Microsoft 365, start with a table whose Code column contains BOX2-017-UK, PEN-42-EU and PAD-006-US.[2][3]
- Select a table cell, then Data → From Table/Range. In the editor, select Code and choose Add Column → Column From Examples → From Selection.
- Enter 017 beside BOX2-017-UK and 42 beside PEN-42-EU; press Ctrl+Enter. Expect 006 for PAD-006-US.
- Inspect the proposed transformation above the preview: it should extract between hyphens. Correct a wrong suggestion by double-clicking that result and providing another example.
- Choose OK and inspect the new Applied Steps entry. Use the column’s type icon to select Text, preserving leading zeros; then Home → Close & Load.
Add CARD9-120-EU to the original table. Select a cell in the loaded results, choose Query → Refresh → Refresh, and expect 120.[4]
Digits in the prefixes catch a rule that simply collects every number.
Sources & further reading
- Add a column from examples Microsoft Learn · Accessed 20 Oct 2026
- Add a column from an example (Power Query) Microsoft Support · Accessed 20 Oct 2026
- Import from an Excel table Microsoft Support · Accessed 20 Oct 2026
- Refresh an external data connection in Excel Microsoft Support · Accessed 20 Oct 2026
- Data types in Power Query Microsoft Learn · Accessed 20 Oct 2026
- What’s new in Power Query & Dataflows – November 2020 Microsoft Power BI · Accessed 20 Oct 2026