KeepChar(Phone, '0123456789')

KeepChar and PurgeChar in Power BI

In Power Query, Text.Select keeps only the listed characters (KeepChar) and Text.Remove drops them (PurgeChar). Both accept ranges such as {"0".."9"}. DAX has no equivalent. You would need one nested SUBSTITUTE per character, so clean the text in Power Query.

Partial / different approach Power Query

Short answer: Use Text.Select([Phone], {"0".."9"}) for KeepChar and Text.Remove([Name], {"-", ".", " "}) for PurgeChar.

What it does in Qlik

  • KeepChar(text, chars) returns the text with only the characters listed in chars.
  • PurgeChar(text, chars) returns the text with those characters removed.
  • Matching is character by character and case-sensitive.

Qlik example

Qlik script
KeepChar(Phone, '0123456789') AS PhoneDigits,
PurgeChar(SKU, ' -./')        AS SKUClean

Power BI equivalent

Power Query

Power Query M
= Table.AddColumn(Src, "PhoneDigits", each Text.Select([Phone], {"0".."9"}), type text)
= Table.AddColumn(Src, "SKUClean", each Text.Remove([SKU], {" ", "-", ".", "/"}), type text)
// letters and digits only
= Text.Select([Code], {"A".."Z", "a".."z", "0".."9"})

Gotchas and behaviour differences

  • No DAX equivalent. SUBSTITUTE replaces one string at a time, so stripping 10 characters takes 10 nested calls. Do it in Power Query, or upstream in SQL.
  • Ranges follow Unicode order, so {"A".."Z"} excludes accented letters such as É. Add them explicitly if your data has them.

Official documentation

Related pages

Spotted an error or a better pattern? QlikToDax is maintained by a working BI consultant; corrections are welcome via the About page. Last reviewed 2026-10-25.