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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Rochejf
Frequent Visitor

Extract round figure from Text

I try using code below to extract figure from text, it works on round figure but not on float.

 

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

This is my output below.

QUANTITY x 4

4

QUANTITY x 4.0

40

 

The expected output for the second row is 4.

 

How can I extract only 4 when come to this circumstances?

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

pls try this

List.Select(
  Splitter.SplitTextByAnyDelimiter({",", ".", " "})(
    Text.Select([Column1], {"1" .. "9", ",", ".", " "})
  ), 
  each _ <> ""
){0}

Screenshot_1.png

View solution in original post

5 REPLIES 5
Ahmedx
Super User
Super User

pls try this

List.Select(
  Splitter.SplitTextByAnyDelimiter({",", ".", " "})(
    Text.Select([Column1], {"1" .. "9", ",", ".", " "})
  ), 
  each _ <> ""
){0}

Screenshot_1.png

It works. However, there's some empty cell in that column also so it will generate error result

pls try this

 

List.Select(
Splitter.SplitTextByAnyDelimiter({",", ".", " "})(
    Text.Select([Column1], {"0" .. "9", ",", ".", " "})
  ), each List.ContainsAny({_},{"0" .. "9"})){0}

 

amitchandak
Super User
Super User

@Rochejf , First use Text.Replace to remove QUANTITY x and the Use Text.Start to get character 1

 

Power BI- Power Query Conditional Replace Value- https://youtu.be/Qj2bthdusiM

Power Query - Text.Start, Text.Middle, Text.End: https://www.youtube.com/watch?v=vky4wPqm0O0

The text.start is not working. 

 

However, I changed the type to whole number after i did the text.replace so it still somehow do the trick?

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.