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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
tiffanynguyen
Regular Visitor

NaN Error

I created a new field, Cost/Quantity, and the output is coming up at NaN. 

 

I was able to see the Cost by year on a bar chart and quantity by year on a bar chart fine, but when I tried to doing Cost/Quantity on a bar chart, I am not getting anything due to NaN values. How do i fix this?

 

Thanks

1 ACCEPTED SOLUTION

@Vvelardenope, turns out this is a custom column in the query editor. No DIVIDE there.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

11 REPLIES 11
MarcelBeug
Community Champion
Community Champion

Typically you get NaN when dividing 0 by 0.

So adjust your formula something like if Quantity = 0 then 0 else Cost / Quantity.

Specializing in Power Query Formula Language (M)

it is not working for me 


@MarcelBeug wrote:

Typically you get NaN when dividing 0 by 0.

So adjust your formula something like if Quantity = 0 then 0 else Cost / Quantity.


 

THANK YOU! That was so easy to fix. Thank you!

How do i get rid of this? Would I be able to replace it with 0 or null?

@tiffanynguyen

 

hi, use this:

 

Measure=Divide([Cost],[Quantity],0)

 

 




Lima - Peru

super!!!! Thanks Sir!!!!

Anonymous
Not applicable

This worked for me beautifully thank you

@Anonymous

 

How did you write the formula in the custom column?
I have the same issue.

 

Screenshot_1.pngScreenshot_2.png

You're dividing by zero. That's impossible. That's why you're getting the error. You need to put in an if statement to return null when [D_Act_2doTermino] is 0.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@Vvelardenope, turns out this is a custom column in the query editor. No DIVIDE there.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@KHorseman Thanks. Yes, Divide don't apply in query Editor.

 

 




Lima - Peru

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.