Forum Discussion

tiffanynguyen's avatar
tiffanynguyen
Regular Visitor
9 years ago
Solved

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

7 Replies

  • MarcelBeug's avatar
    MarcelBeug
    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.

    • Anonymous's avatar
      Anonymous
      Not applicable

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

      • tiffanynguyen's avatar
        tiffanynguyen
        Regular Visitor

        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?

    • Anonymous's avatar
      Anonymous
      Not applicable

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