Forum Discussion

jaryszek's avatar
jaryszek
Super User
4 years ago
Solved

Change column type when row values are mixed

Hi Guys,   my table is: Col1Col2Col3 AB 05 BRE CD SomeString ACB   as you can see Col2 has text but what i want is to change "05" to 5 because as a goal it will be integer.  How c...
  • Payeras_BI's avatar
    4 years ago

    Hi again jaryszek ,

    I was now thinking that you won't only have an integer in your column but many.

    Please try this other option:

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnRS0lEyMAUSTkGuSrE60UrOLkBOcH5uanBJUWZeOpDj6OwElnF1A3IMDYGEe4ijUmwsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]),
        Transformation = Table.TransformColumns(Source,{{"Column2", each try Int64.From(_) otherwise _}})
    in
        Transformation