cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tiffanynguyen Frequent Visitor
Frequent 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

Accepted Solutions
KHorseman Super Contributor
Super Contributor

Re: NaN Error

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


Did I answer your question? Please mark it as a solution.

Proud to be a Datanaut!

View solution in original post

11 REPLIES 11
MarcelBeug Super Contributor
Super Contributor

Re: NaN Error

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)
Highlighted
tiffanynguyen Frequent Visitor
Frequent Visitor

Re: NaN Error

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

Vvelarde Super Contributor
Super Contributor

Re: NaN Error

@tiffanynguyen

 

hi, use this:

 

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

 

 




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

Proud to be a Datanaut!




KHorseman Super Contributor
Super Contributor

Re: NaN Error

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


Did I answer your question? Please mark it as a solution.

Proud to be a Datanaut!

View solution in original post

Vvelarde Super Contributor
Super Contributor

Re: NaN Error

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

 

 




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

Proud to be a Datanaut!




TaniaSteenkamp Frequent Visitor
Frequent Visitor

Re: NaN Error

This worked for me beautifully thank you

gabrielvigo Regular Visitor
Regular Visitor

Re: NaN Error

@TaniaSteenkamp

 

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

 

Screenshot_1.pngScreenshot_2.png

KHorseman Super Contributor
Super Contributor

Re: NaN Error

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? Please mark it as a solution.

Proud to be a Datanaut!
K_Altman Frequent Visitor
Frequent Visitor

Re: NaN Error

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

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 104 members 1,443 guests
Please welcome our newest community members: