Power Query: Extract Numbers from a Text String

Mar 13, 2025
1 min read
Updated: Oct 3
PRACTICE MATERIAL BELOW!👇
Function: Extracts only the numeric values from a given text. Simply add custom function in Power Query and define your column.

Usage:
= ExtractNumbers("Order ID: 123ABC456") → Returns: "123456"Power Query code for use and reuse:
let
ExtractNumbers = (inputText as nullable text) as nullable text =>
let
NumbersOnly =
if inputText = null then null
else Text.Select(inputText, {"0".."9"})
in
NumbersOnly
in
ExtractNumbers

Need a code and instructions? Free of charge =)
Reuse your Power Query work
Build on this text-cleaning technique with reusable Power Query transformation patterns.
Need help adapting this to your data? Discuss your project.





Comments