Need to replace "Infinity" output with something else

Hello,
I'm getting an output of "Infinity" when I divide a number in to zero, which makes sense. I need to know how to convert that "Infinity" output in to something else, like a zero or "Budget Not Set", basically anything other than "Infinity". The data comes in through SQL, so sometimes there is not labor budget available to divide in to. I've attached a screenshot below of my current output example when this is the case:



And the below code I currently have for that particular PivotView:
var pivotTableObj1 = new ej.pivotview.PivotView({
     dataSourceSettings: {
     dataSource: data,
     expandAll: false,
     showGrandTotals: false,
     values: [
          { name: 'unit_budget'caption: 'Unit Budget' },
          { name: 'production'caption: 'Units Completed' },
          { name: 'Units_Remaining'caption: 'Units Remaining'type: 'CalculatedField' },
          { name: 'Pct_Units_Completed'caption: '% Units Completed'type: 'CalculatedField' },
          { name: 'item_rate'caption: 'Labor Cost Per Unit' },
          { name: 'estimated_labor_cost'caption: 'Estimated Labor Cost' },
          { name: 'actual_employee_st_cost'caption: 'Actual Labor Reg' },
          { name: 'actual_employee_ot_cost'caption: 'Actual Labor OT' },
          { name: 'actual_employee_labor_cost'caption: 'Actual Labor Cost' },
          { name: 'Labor_Variance'caption: 'Labor Variance'type: 'CalculatedField' },
          { name: 'labor_budget'caption: 'Total Labor Budget' },
          { name: 'Remaining_Labor_Budget'caption: 'Remaining Labor Budget'type: 'CalculatedField' },
          { name: 'Pct_Budget_Completed'caption: '% Budget Completed'type: 'CalculatedField' }
          ],
     filters: [
          { name: 'production_bool' }
          ],
     rows: [
      { name: 'item'caption: 'Item Code' }
          ],
     filterSettings: [
          { name: 'production_bool'type: 'Exclude'items: ['Labor'] }
          ],
     formatSettings: [
          { name: 'unit_budget'format: '#,###.00' },
          { name: 'production'format: '#,###.00' },
          { name: 'Units_Remaining'format: '#,###.00' },
          { name: 'Pct_Units_Completed'format: 'P2' },
          { name: 'production'format: '#,###.00' },
          { name: 'item_rate'format: '$#,###.00' },
          { name: 'estimated_labor_cost'format: '$#,###.00' },
          { name: 'actual_employee_st_cost'format: '$#,###.00' },
          { name: 'actual_employee_ot_cost'format: '$#,###.00' },
          { name: 'actual_employee_labor_cost'format: '$#,###.00' },
          { name: 'Labor_Variance'format: '$#,###.00' },
          { name: 'labor_budget'format: '$#,###.00' },
          { name: 'Remaining_Labor_Budget'format: '$#,###.00' }
          ],
     calculatedFieldSettings: [
          { name: 'Units_Remaining'formula: '"Sum(unit_budget)"-"Sum(production)"' },
          { name: 'Pct_Units_Completed'formula: '"Sum(production)"/"Sum(unit_budget)"' },
          { name: 'Labor_Variance'formula: '"Sum(estimated_labor_cost)"-"Sum(actual_employee_labor_cost)"' },
          { name: 'Remaining_Labor_Budget'formula: '"Sum(labor_budget)"-"Sum(actual_employee_labor_cost)"' },
          { name: 'Pct_Budget_Completed'formula: '"Sum(actual_employee_labor_cost)"/"Sum(labor_budget)"' }
          ]
     },
     gridSettings: gSettings,
     allowCalculatedField: true,
     showTooltip: false,
     height: objHeight
});

Please let me know how I can capture the "Infinity" and output something else. Thank you!

3 Replies 1 reply marked as answer

MM Manikandan Murugesan Syncfusion Team May 13, 2021 08:37 AM UTC

Hi Val Jensen, 
 
Please set your desired text in-place of Infinity by using aggregateCellInfo event. Please refer the following code example and sample. 
Code Snippet: 
var pivotObj = new ej.pivotview.PivotView({ 
    aggregateCellInfo: function (args) { 
      if (args.value === Infinity) { 
        args.value = 0; 
      } 
    } 
}); 
pivotObj.appendTo('#PivotView'); 
 
 
 
Please let us know if you have any other queries. 
 
Thanks, 
Manikandan 


Marked as answer

VJ Val Jensen May 13, 2021 03:10 PM UTC

Hello Manikandan,
Thank you very much for the code example; it works wonderfully!


ME Mouli Eswararao Syncfusion Team May 14, 2021 01:56 PM UTC

Hi Val Jensen, 

Thanks for the reply. Please let us know if you need any further assistance on this. 

Regards, 
Sastha Prathap S.

Loader.
Up arrow icon