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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply

Need help to replace NaN values

Hi,
I am trying to replace NaN values in my table with following M code

virendrajadhav1_0-1691041435509.png

#"remove_nan" = Table.TransformColumnNames(#"Rounded Off2",{{"q_to_p", each if Number.IsNaN(_) then 0 else _,type number}})

But when I hit enter, I get Expression.Error: We cannot convert a value of type List to type Function.

virendrajadhav1_1-1691041537856.png

Kindly suggest how I can fix this?

2 ACCEPTED SOLUTIONS
wdx223_Daniel
Community Champion
Community Champion

you may use the function of Table.TransformColumns, instead of Table.TransformColumnNames

View solution in original post

if you want to remove the value from columns regardless of column names, can try this code

=Table.TransformColumns(PreviousStepName,{},each if _ is number and Number.IsNaN(_) then 0 else _)

View solution in original post

4 REPLIES 4
wdx223_Daniel
Community Champion
Community Champion

you may use the function of Table.TransformColumns, instead of Table.TransformColumnNames

Daniel, Thank you. It worked. 
One added question, if I have to add another seperate line of code which removes "Infinity" from the coloums, how should I do that? 

if you want to remove the value from columns regardless of column names, can try this code

=Table.TransformColumns(PreviousStepName,{},each if _ is number and Number.IsNaN(_) then 0 else _)

Daniel, Thanks much. Really appreciate your help. 🙂 

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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

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