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
Hi Jimmy801 ,
I cannot understnad this part of the code:
FromText("i45WcjRUitWJVjI2BlNRUWDKACIIlXN2hshBeJaWECUGSrGxAA==",)
Should I be updatin this?
Hello Anonymous
you can copy paste my first code as formula of a new custom column, adapting the column reference. Or you copy paste the second code into your advanced editor to see a whole example, just as Anonymous was writing.
Hope this helps
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
- Anonymous5 years agoNot applicable
Hi Jimmy801 , how do I view in advanced editor? you solution worked on mine.thanks!
I just want to view in code uisng advanced editor. Sorry newbie question.