Remove Digits or Keep them in Power BI Using Power Query

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail
FacebooktwitterlinkedinrssyoutubeFacebooktwitterlinkedinrssyoutube

There are a couple of useful actions that help a lot in cleaning data; removing digits, or keeping digits and removing everything else. In this short blog article, I’ll explain a simple method to do that using Power Query.

Sample Data

My sample data table looks like this:

sample input data

Removing Digits

I can easily get rid of all digits wherever they are, using this action: adding a custom column:

Add Custom Column

Then the expression below (remember to use your column name instead of Column1 in the below expression):

And here is the result;

all digits removed

Digits would be removed regardless of where they are in the text easily using the Text.Remove Power Query Function. And I used a list of digits from zero to nine to have all the range included.

Keeping Digits, Removing Everything Else

If you want to do the opposite of this action, after creating a custom column, you can use the code below;

This is, in fact, the opposite of previous action, it first finds all non digits (similar to the previous process), and then removes them to have only digits. and here is the result:

Keeping digits only

There are other methods to achieve the same results as well, however, these methods work simple and workable.

Video

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail
FacebooktwitterlinkedinrssyoutubeFacebooktwitterlinkedinrssyoutube
Reza Rad on FacebookReza Rad on LinkedinReza Rad on TwitterReza Rad on Youtube
Reza Rad
Trainer, Consultant, Mentor
Reza Rad is a Microsoft Regional Director, an Author, Trainer, Speaker and Consultant. He has a BSc in Computer engineering; he has more than 20 years’ experience in data analysis, BI, databases, programming, and development mostly on Microsoft technologies. He is a Microsoft Data Platform MVP for nine continuous years (from 2011 till now) for his dedication in Microsoft BI. Reza is an active blogger and co-founder of RADACAD. Reza is also co-founder and co-organizer of Difinity conference in New Zealand.
His articles on different aspects of technologies, especially on MS BI, can be found on his blog: https://radacad.com/blog.
He wrote some books on MS SQL BI and also is writing some others, He was also an active member on online technical forums such as MSDN and Experts-Exchange, and was a moderator of MSDN SQL Server forums, and is an MCP, MCSE, and MCITP of BI. He is the leader of the New Zealand Business Intelligence users group. He is also the author of very popular book Power BI from Rookie to Rock Star, which is free with more than 1700 pages of content and the Power BI Pro Architecture published by Apress.
He is an International Speaker in Microsoft Ignite, Microsoft Business Applications Summit, Data Insight Summit, PASS Summit, SQL Saturday and SQL user groups. And He is a Microsoft Certified Trainer.
Reza’s passion is to help you find the best data solution, he is Data enthusiast.

3 thoughts on “Remove Digits or Keep them in Power BI Using Power Query

Leave a Reply

%d bloggers like this: