Replace N/A values with 0 in indicators

Comments

10 comments

  • Avatar
    Robert Vaughan

    This script works great for an indicator with a single value,  when you add a secondary value is displays a blank.   Does anyone know how to handle this result i.e. when there is a secondary values on the indicator that is not null?

    1
    Comment actions Permalink
  • Avatar
    Jessica Orlando

    It seems this script broke in 8.1.1 and the 0 no longer shows up, just the label of the indicator.

    0
    Comment actions Permalink
  • Avatar
    Ben Sadan (Edited )

    Hi Robert Vaughan and Jessica Orlando

    replace the code you have with this, it will fix both of these problems!

    widget.on('render', function (w, q) {
    if(w.queryResult.value.text == "")
    {
    w.queryResult.value.data = 0;
    w.queryResult.value.text = 0;
    }

    if(w.queryResult.secondary != null && w.queryResult.secondary.text == "")
    {
    w.queryResult.secondary.data = 0;
    w.queryResult.secondary.text = 0;
    }
    })
    0
    Comment actions Permalink
  • Avatar
    Jessica Orlando

    Thanks Ben!

    0
    Comment actions Permalink
  • Avatar
    Brian Wilson

    Thank you, Ben!

    0
    Comment actions Permalink
  • Avatar
    Paul Furman

    Hi, Ben Sadan!

    Thank you very much for the code!

    This code does not work for me, unfortunately.   My primary value is a basic DUPCOUNT; however, the secondary one is PASTMONTH of it.

    Both are 0 and it displays as such for the primary; however, still displays #N/A for the secondary.

    Any help would be appreciated!

     

    0
    Comment actions Permalink
  • Avatar
    Pramata Corporation

    Hi Ben Sadan

    This code seems to work for counts but not with sum. 
    If the indicator is using a Sum value, even with the code the result still shows "N/A".

    Could you please help with this?

    0
    Comment actions Permalink
  • Avatar
    Ben Sadan (Edited )

    hi Pramata Corporation,

    here is an update for the script to take the N/A into account and display it as 0

    hope this helps!

    widget.on('render', function (w, q) {
    if(w.queryResult.value.text == "" || w.queryResult.value.text == "#N/A")
    {
    w.queryResult.value.data = 0;
    w.queryResult.value.text = 0;
    }

    if(w.queryResult.secondary != null && (w.queryResult.secondary.text == "" || w.queryResult.value.text == "#N/A"))
    {
    w.queryResult.secondary.data = 0;
    w.queryResult.secondary.text = 0;
    }
    })
    1
    Comment actions Permalink
  • Avatar
    Alan Broner

    Hi Ben Sadan ,

    It works perfectly. Thank you very much for your help.

    Best,

    0
    Comment actions Permalink
  • Avatar
    Zcost Server

    This code is based  the type of the returned data

    widget.on('render', function (w, q) {	
    if (isNaN(w.queryResult.value.data) === true)
    {
    w.queryResult.value.data = 0;
    w.queryResult.value.text = "0";
    }

    if(w.queryResult.secondary != null && isNaN(w.queryResult.secondary.data) === true)
    {
    w.queryResult.secondary.data = 0;
    w.queryResult.secondary.text = "0";
    }
    })
    0
    Comment actions Permalink

Please sign in to leave a comment.