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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

If Otherwise error

Hi,

I have below line:

 

= Table.TransformColumnTypes(#"Filtered Rows",{{"userId", Int64.Type}})

 

this changes column to whole numbers, on some lines this drops errors. I have tried below

 

= try Table.TransformColumnTypes(#"Filtered Rows",{{"userId", Int64.Type}}) otherwise null

 

but it doesn't work. It still shows errors.

 

What I would like achieve is:

 

convert to whole numbers, if error leave as text

 

thanks

dan

1 ACCEPTED SOLUTION
Jimmy801
Community Champion
Community Champion

Hello @Anonymous 

 

this is because Table.TransformColumnTypes is applied at once. When you get an error means that the content isn't suitable for the change. However this means the column type can't be changed - only on cell level. This can be achieved by applying a TransformColumns only. See here an example

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxmAyMSkZTOvqgqmS1OISpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Number = _t]),
    TransformColumn =Table.TransformColumn
    (
        Source,
        {
            {
                "Number", each try Number.From(_) otherwise _, type any
            }
        }
    )
in
    TransformColumn

Copy paste this code to the advanced editor to see how the solution works

 

If this post helps or solves your problem, please mark it as solution.
Kudos are nice to - thanks
Have fun

Jimmy

View solution in original post

2 REPLIES 2
Jimmy801
Community Champion
Community Champion

Hello @Anonymous 

 

this is because Table.TransformColumnTypes is applied at once. When you get an error means that the content isn't suitable for the change. However this means the column type can't be changed - only on cell level. This can be achieved by applying a TransformColumns only. See here an example

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxmAyMSkZTOvqgqmS1OISpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Number = _t]),
    TransformColumn =Table.TransformColumn
    (
        Source,
        {
            {
                "Number", each try Number.From(_) otherwise _, type any
            }
        }
    )
in
    TransformColumn

Copy paste this code to the advanced editor to see how the solution works

 

If this post helps or solves your problem, please mark it as solution.
Kudos are nice to - thanks
Have fun

Jimmy

Anonymous
Not applicable

Hi,

thanks for explanation, much appreciated.

 

dan

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.