14
Views
3
Comments
NaN value in table
Question
Application Type
Reactive
Service Studio Version
11.9.2 (Build 33932)
Platform Version
11.10.0 (Build 22422)

I have a table that is doing basic calculations and displaying them.  The calculation is number of items served/total served, which gives a percentage.  If there is 0/0 obviously this would return a 0 but in the value it returns a NaN.  How do I convert it so the value shows up a 0 and not NaN?  Any help or guidance would be appreciated.

mvp_badge
MVP
Rank: #19

Hi Peter,

Mathematically 0/0 isn't 0... it's undefined (hence the JavaScript value of Not a Number). Are you doing these calculations in a JavaScript node? If so, you can always use the JavaScript method Number.isNaN(your_value) to determine if the value should be displayed as is or if something else should be displayed (like "", an "-" or 0).

Hope this helps!

Rank: #3150

Thanks everyone, I was able to just do an if statement on the expression and if the denominator was <=0 then all i did was display 0% like we needed.