cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
IdeF
Frequent Visitor

Extracting number from a text field with description then making colum

So I have a feild named descrpition that described spillage incidents....... Each colum in this fieild will have a volume (in liters) of the amount product spilled. I want to create a colum that will seach through each field and find whatever number is befor the word/letters "litre" and have that number in a colum..... The sentance below is of how the description field typically looks looks. "An incident occured whre a truck rolled over and spilled over 1264 litres of fuel ect.." or "A woker tripped and feel on a container resulting in 123litres of fuel being spilled" some times theres a space after the digits sometimes not... Can anyone assist me with this

 
 
 
 
 

 

1 ACCEPTED SOLUTION

@IdeF in that case, since I would need some examples of data to test it out, my suggestion to you would be to do the following:
Select your column -> Add Column -> Column from examples (be sure to select the "From selection" option in the drop down menu)

goncalogeraldes_0-1689151389057.png

Fill in some examples (until you see that Power Query starts suggesting values correctly) and name your new column. 

goncalogeraldes_1-1689151561084.png

Another possibility is to manually add a step in the query with following code:

 

= Table.AddColumn(PreviousStepName, "Extracted Numbers", each Text.BetweenDelimiters([Column_with_text_string], "", "liters"), type number)

 

Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍
Thanks!

You can also check out my LinkedIn!

Best regards,
Gonçalo Geraldes

View solution in original post

3 REPLIES 3
goncalogeraldes
Super User
Super User

Hi @IdeF , assuming that the only numbers present in the string are those you mentioned, you can do the following:

Go to "Add Column" -> "Custom Column" -> Paste a code similar to (replace with your column name)

Text.Select( [Sentence], {"0".."9"} )

goncalogeraldes_0-1689075337919.png

Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍
Thanks!

You can also check out my LinkedIn!

Best regards,
Gonçalo Geraldes

The issue I only want digits that are before the words(text) "litres".... Since the sentance containce other didgits, can you assist me with that..

 

@IdeF in that case, since I would need some examples of data to test it out, my suggestion to you would be to do the following:
Select your column -> Add Column -> Column from examples (be sure to select the "From selection" option in the drop down menu)

goncalogeraldes_0-1689151389057.png

Fill in some examples (until you see that Power Query starts suggesting values correctly) and name your new column. 

goncalogeraldes_1-1689151561084.png

Another possibility is to manually add a step in the query with following code:

 

= Table.AddColumn(PreviousStepName, "Extracted Numbers", each Text.BetweenDelimiters([Column_with_text_string], "", "liters"), type number)

 

Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍
Thanks!

You can also check out my LinkedIn!

Best regards,
Gonçalo Geraldes

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors