Forum Discussion
jaryszek
4 years agoSuper User
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...
- 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
Payeras_BI
4 years agoSolution Sage
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
- jaryszek4 years agoSuper User
thabk you very much!
try Int64.From(_) otherwise _How this will work?
What does "_" mean ?
And what if i want to check Column5 also, can i create getType function to check ? Assume that i have also logical types in the table.
So i want to check every column and check if this is potential type.
If Int64.type then replace, if logical change to logicalm, if string change to string.
Thank you,
Jacek