Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Unicorn_Tech
Resolver I
Resolver I

Get 3 digit numbers from text string

i have strings in a column that look like this:

Company NL #496

486 NL for the company
#501 NL

 

I want to create a new column that just features the 3 digit code.  What formula can I use to do this?  I'm having trouble with "Text.Select"

1 ACCEPTED SOLUTION

Here is the step by step process of achieving it:

1) Go to Transform Data:

PC2790_0-1613559892067.png

2) Now open "Advanced Editor"

PC2790_1-1613560019535.png

3)  Now add the M query in your code something as below:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcs7PLUjMq1Tw81FQNrE0U4rViVYysTAD8dPyixRKMlIVkiFKwFLKpgaGQDml2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"New Column"= Table.AddColumn(#"Changed Type", "New", each Text.Select([Column1], {"0".."9"}))
in
    #"New Column"

I hope this will give you some clarity 

 

 

 

 

View solution in original post

5 REPLIES 5
Tahreem24
Super User
Super User

@Unicorn_Tech ,

You can also take the help of this below post:

https://www.excelnaccess.com/extract-numbers-text-only-from-sentences/

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
PC2790
Community Champion
Community Champion

Hi @Unicorn_Tech ,

 

Try this M code in the Power query:

 

= Table.AddColumn(#"Changed Type", "New", each Text.Select([Column1], {"0".."9"}))

The result will look something like this:

 

PC2790_0-1613554735572.png

 

 

Hi @PC2790 ,

It looks great, but I'm not familiar with M code and power query.  I am used to adding columns in existing tables, will this solution work that way?

Here is the step by step process of achieving it:

1) Go to Transform Data:

PC2790_0-1613559892067.png

2) Now open "Advanced Editor"

PC2790_1-1613560019535.png

3)  Now add the M query in your code something as below:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcs7PLUjMq1Tw81FQNrE0U4rViVYysTAD8dPyixRKMlIVkiFKwFLKpgaGQDml2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"New Column"= Table.AddColumn(#"Changed Type", "New", each Text.Select([Column1], {"0".."9"}))
in
    #"New Column"

I hope this will give you some clarity 

 

 

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.