Forum Discussion

wallingfordce's avatar
wallingfordce
Data Pipeline
11-16-2022
Solved

RSUM with Display Missing as Zero

When using the feature to Display Missing Values as Zeros, the results are what I would expect for a simple SUM. However, for an RSUM the results should fold the zeros into the value within RSUM and ...
  • Harry's avatar
    11-16-2022

    Hello wallingfordce ,

    Try this widget script. (update the variable 'panelName' with name of panel with RSUM calculation)

    
    widget.on('processresult', function(se, ev){
    	
    	var panelName = 'RSUM(Total Quantity (1))'
    	
    	var series = ev.result.series.find(el => el.name == panelName)
    	var prevValue = series.data[0].y
    	
    	$.each(series.data, function(index, value){
    		if(value.y == null)
    			value.y = prevValue
    		else
    			prevValue = value.y	
    	})
    	
    })

    Please let me know if you have any questions

    Always here to help,
    Harry from QBeeQ

    QBeeQ - Gold Implementation and Development Partner
    www.qbeeq.pl

     

  • harikm007's avatar
    harikm007
    12-23-2022

    When there is a 'break by', we need to add $.each on Series as below:

    widget.on('processresult', function(se, ev){
    	
    	$.each(ev.result.series, function(seriesIndex, seriesValue){
    		
    		var prevValue = seriesValue.data[0].y
    
    		$.each(seriesValue.data, function(index, value){
    			if(value.y == null)
    				value.y = prevValue
    			else
    				prevValue = value.y	
    		})
    	
    	})	
    
    })

    -Hari