Forum Discussion

lotus22's avatar
lotus22
Helper III
5 years ago
Solved

DAX formula: Extract Numbers from String and create new column

How can I extract numbers from String using DAX formula to create new column?

 

Create a new column: I need to extract numbers from a string where possible otherwise list the numbers as is if no string exists. The easy part is, wherever string exist, numbers are always followed by "tm". Maybe we can split anything before "tm".

 

1589tmpem
169tmpem
178tmpj
167
163
1765tmpem
 

 

 

  • lotus22 add a new column in power Query with following M code and then change the type to number

     

    Text.BeforeDelimiter([col],"tm")

     

     

    Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

     

1 Reply

  • lotus22 add a new column in power Query with following M code and then change the type to number

     

    Text.BeforeDelimiter([col],"tm")

     

     

    Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.