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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
tiffanynguyen
Regular 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

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? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

7 REPLIES 7
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)
Anonymous
Not applicable

Thanks, @MarcelBeug I had the same issue, found this solution, and fixed the error. 🙂

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





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

Proud to be a Super User!




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?

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? Mark my post as a solution!

Proud to be a Super User!




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

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? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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