Forum Discussion

frankmol's avatar
frankmol
Cloud Apps
06-13-2023
Solved

Replacin 'NULL' with '0' in in calculations for column chart and pivot table

Hi all,   For a culumn chart  I calculated averages and divided the percentages into segments, the percentages do not add up to 100% After some searching I found out that this is because the 'NULL...
  • Sijo1995's avatar
    06-15-2023

    Hi frankmol ,

    https://community.sisense.com/t5/build-analytics/nulls-to-0-in-pivot/td-p/14777 

    Please try this script

     

     

    function replaceNullsWithZeros(data) {
      for (var i = 0; i < data.length; i++) {
        for (var j = 0; j < data[i].length; j++) {
          if (data[i][j] === null) {
            data[i][j] = 0;
          }
        }
      }
      return data;
    }
    
    // Replace all NULL values in the pivot table with 0
    widget.on('processresult', function(sender, ev) {
      ev.result = replaceNullsWithZeros(ev.result);
    });

     

    And please read this document-https://community.sisense.com/t5/build-analytics/nulls-to-0-in-pivot/td-p/14777

     

    Thanks

    Sijo