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
qmest
Frequent Visitor

Retrieving numbers from column with text and numbers

Hi,

 

I have a column in a table that mixes several types of values. Numbers, text, symbols and null values. How can i build a separate column that has only the numeric values and ignores all the others. I've tried the following but didn't work:

 

if [ANSWER_VALUE] is number then [ANSWER_VALUE] else 999

 

Thanks.

 

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @qmest ,

 

Try using this in a new custom column:

Table.AddColumn(
  previousStep,
  "newColumnName",
  each Text.Combine(
    List.RemoveNulls(
      List.Transform(
        Text.ToList([ANSWER_VALUE]),
        each if Value.Is(Value.FromText(_), type number) then _ else null
      )
    )
  )
)

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

3 REPLIES 3
CNENFRNL
Community Champion
Community Champion

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyVorViVZydHIG02AiptTAwMisLk4pNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Mixed = _t]),
    #"Only Numeric" = Table.AddColumn(Source, "Numeric", each try Number.From([Mixed])??999 otherwise 999)
in
    #"Only Numeric"

Screenshot 2021-11-18 164458.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

BA_Pete
Super User
Super User

Hi @qmest ,

 

Try using this in a new custom column:

Table.AddColumn(
  previousStep,
  "newColumnName",
  each Text.Combine(
    List.RemoveNulls(
      List.Transform(
        Text.ToList([ANSWER_VALUE]),
        each if Value.Is(Value.FromText(_), type number) then _ else null
      )
    )
  )
)

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




qmest
Frequent Visitor

Perfect. Thank you!

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.

Top Solution Authors