Forum

NaN Error when Divi...
 
Notifications
Clear all

NaN Error when Dividing with Zero

3 Posts
2 Users
0 Reactions
1,740 Views
 P B
(@peace)
Posts: 34
Trusted Member
Topic starter
 

Hello Mynda,

What is the best approach to handle NaN Errors in Power Query? I have a table which is using a couple of columns but I am concerned about  2 Columns for this calculation and that is A and B and the calculation is to be in %. The Formula my company is using is like this 

=A2/(A2+B2) This calculation will go into the 3rd column.

And now there are some records where values are zero. 

So two issues over here. When I Close and Load to the Table it will show me 4 errors and if I click on 4 Errors and it takes me back to PQ and over there it shows me those records where all values are zero in these 2 columns and 3rd column will show an error, NaN.

I used a Custom Column and used this Formula  =A2/(A2+B2) (Replacing it with actual column names).

Is there a better way to do this?

How do I change Values for NaN Errors?

I can't replace Values of NaN with anything else. I wanted to put value like Undetermined or Undefined (That is what it is when you divide with 0)

Please advise

Thanks,

PB

NaN-Error-2021-04-21_18-30-45.png

 
Posted : 22/04/2021 7:01 pm
(@mynda)
Posts: 4761
Member Admin
 

Hi PB,

There is a function for NaN values which you can use in a custom column:

= if Number.IsNaN([A]/([A]+)) then null else [A]/([A]+)

Mynda

 
Posted : 23/04/2021 2:10 am
 P B
(@peace)
Posts: 34
Trusted Member
Topic starter
 

Hello Mynda,

 

Thank you! I will try it right now.

 

Thanks,

PB

 
Posted : 23/04/2021 7:42 am
Share: