protected void pivotIndicador_ItemNeedCalculation(object sender, Telerik.Web.UI.PivotGridCalculationEventArgs e) { if (e.DataField == "Indicador") { AggregateValue TotalRenovada = e.GetAggregateValue("TotalRenovada"); AggregateValue TotalRefinanciada = e.GetAggregateValue("TotalRefinanciada"); AggregateValue DeudaTotal = e.GetAggregateValue("DeudaTotal"); if (TotalRenovada != null && TotalRefinanciada != null && DeudaTotal != null) { decimal val_TotalRenovada = (decimal)TotalRenovada.GetValue(); decimal val_TotalRefinanciada = (decimal)TotalRefinanciada.GetValue(); decimal val_DeudaTotal = (decimal)DeudaTotal.GetValue(); if (val_DeudaTotal == 0) { e.CalculatedValue = new DoubleAggregateValue(0); } else { double resultado = Convert.ToDouble(((val_TotalRenovada + val_TotalRefinanciada) / val_DeudaTotal) * 100); e.CalculatedValue = new DoubleAggregateValue(resultado); } } } }
/// <inheritdoc /> protected internal override void FormatTotals(IReadOnlyList <TotalValue> valueFormatters, IAggregateResultProvider results) { double accumulation = 0; foreach (var valueFormatter in valueFormatters) { AggregateValue value = valueFormatter.Value; if (value != null) { accumulation += Convert.ToDouble(value.GetValue(), CultureInfo.InvariantCulture); } valueFormatter.FormattedValue = new ConstantValueAggregate(accumulation); } }