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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
avininpowerbi
Frequent Visitor

trying to check whether a text column contains a number using M

 

I am handling a column , it has majorly text values but occasinally some number values that are similar to  1234.4567, 1234.5678 or 3222.7869 type numbers . ( pls note all of these numbers has four whole digits and 4 decimals) . All these numbers need to be mappe to a single name say X . 

 

I am using if Value.Is([Column], Number.Type) then "X" else "P".  but no luck so far 😞

 

can somone help pls. 

5 REPLIES 5
tackytechtom
Super User
Super User

Hi @avininpowerbi ,

 

How about this:

tackytechtom_0-1675459395835.png

 

Here the code for the logic in the custom column:

try if Value.Is (Number.FromText([Column]), Decimal.Type) then "X" else [Column] otherwise [Column]


/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Hi Tom, 

 

I did try , its threw all errors ! even the normal text has turned into errors. 

 

Any idea ? 

 

 

Hi @avininpowerbi,

 

Could you provide a screenshot of the data as well as of the code for the custom column?

 

thanks 🙂

 

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Thanks for your help !  since I had no luck extracting the numbers, I used  Replace Value ( .00 as the string) with XYZ. Then after, I added a conditional column and used Text.contains . Thats it. 

Daryl-Lynch-Bzy
Resident Rockstar
Resident Rockstar

Hi @avininpowerbi  - you need to try converting the Text to number to find value, and include otherwise for text values.  Like this:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSkxKVorViVaqqKwC04ZGxiZ6pmbmFkqxsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Text = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Add Test", each try Value.Is( Number.From( [Text] ), Number.Type ) otherwise false)
in
    #"Added Custom"

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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

Top Solution Authors