cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tiffanynguyen Frequent Visitor
Frequent Visitor

NaN help

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 help

The query editor uses a different language. It is case sensitive and if statements have a different structure there. You should familiarize yourself with the query editor language. https://msdn.microsoft.com/en-us/library/mt211003.aspx


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

Proud to be a Datanaut!

View solution in original post

6 REPLIES 6
MarcelBeug Super Contributor
Super Contributor

Re: NaN help

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)
KHorseman Super Contributor
Super Contributor

Re: NaN help

...or use the DIVIDE function since it has built-in /0 catching.


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

Proud to be a Datanaut!
Highlighted
tiffanynguyen Frequent Visitor
Frequent Visitor

Re: NaN help

I am a newbie to PowerBI. How do i use the DIVIDE function when i created a custom column? Do I have to go to Advanced Editor?

KHorseman Super Contributor
Super Contributor

Re: NaN help

Oh,  you're in the query editor. No, DIVIDE is a DAX function. You'll have to go with the if 0 suggestion from @MarcelBeug after all.


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

Proud to be a Datanaut!
tiffanynguyen Frequent Visitor
Frequent Visitor

Re: NaN help

Thanks. it says that the If function is not recognized? Should I move to DAX to do this?

KHorseman Super Contributor
Super Contributor

Re: NaN help

The query editor uses a different language. It is case sensitive and if statements have a different structure there. You should familiarize yourself with the query editor language. https://msdn.microsoft.com/en-us/library/mt211003.aspx


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

Proud to be a Datanaut!

View solution in original post

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: 412 members 3,634 guests
Please welcome our newest community members: