Forum Discussion
Mcode: Custom Column- Evaluate IF Text Column has Number Value
- 5 years ago
Hello Anonymous
you can add a custom column with this formula (you have to replace "Column1" with your real column name)
if List.AllTrue(List.Transform(Text.ToList([Column1]), each try Value.Is(Number.From(_), type number) otherwise false)) then "numeric" else "alpha numeric"Here the complete code example
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjRUitWJVjI2BlNRUWDKACIIlXN2hshBeJaWECUGSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if List.AllTrue(List.Transform(Text.ToList([Column1]), each try Value.Is(Number.From(_), type number) otherwise false)) then "numeric" else "alpha numeric") in #"Added Custom"Copy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
Anonymous
Create custome column like below
if Text.Contains("0123456789",Text.Start([ID],1)) and Text.Contains("0123456789",Text.End([ID],1)) then "Number" else "Alpha"
Thanks for you inputs gvrajesh for both solution I always get Token Comma expected error, even if I written all the codes from your solution. Thanks for your inputs!