< /ul>
Die Werte für die Menge und M2 werden unter Jahr gruppiert und wöchentlich angezeigt. Das Zoll -Ereignis. Ich habe erfolgreich ein Changeratio -Feld erstellt und es unter der Gesamtfläche gezeigt. Da es jedoch zu dem Datenbereich hinzugefügt werden musste, um in der Gesamtsumme zu erscheinen, tauchte es auch unter jedem Jahr an, aber als leere Spalten - was ich nicht will. eine Gesamtsumme) ohne jedes Jahr
leere Spalten zu zeigen? (Menge [zweites Jahr] - Menge [Firstyar]) * 100 /Menge [Firstyear] < /p>
< /blockquote>
Alles, was ich brauche, ist, dieses Verhältnis in einer neuen Spalte zu zeigen. Abgelaufen, aber wir planen, es sehr bald bei interner Genehmigung zu erneuern. < /p>
//My Object
public partial class Turnover
{
public int YEAR { get; set; }
public int WEEK { get; set; }
public double M2 { get; set; }
public double AMOUNT_EURO { get; set; }
}
< /code>
PivotGridField fieldDegisim = new PivotGridField("CHANGE_RATIO", PivotArea.DataArea);
fieldDegisim.Caption = "Change Ratio(%)";
fieldDegisim.UnboundType = DevExpress.Data.UnboundColumnType.Decimal;
fieldDegisim.SummaryType = PivotSummaryType.Custom;
fieldDegisim.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
fieldDegisim.CellFormat.FormatString = "p2";
pivotGridControl1.Fields.Add(fieldDegisim);
< /code>
pivotGridControl1.CustomSummary += pivotGridControl1_CustomSummary;
< /code>
private void pivotGridControl1_CustomSummary(object sender,
PivotGridCustomSummaryEventArgs e)
{
if (e.DataField.FieldName != "CHANGE_RATIO")
return;
var drill = e.CreateDrillDownDataSource();
Dictionary yearAmount = new Dictionary();
foreach (PivotDrillDownDataRow row in drill)
{
if (row["YEAR"] == DBNull.Value || row["AMOUNT_EURO"] == DBNull.Value)
continue;
int year = Convert.ToInt32(row["YEAR"]);
double amount = Convert.ToDouble(row["AMOUNT_EURO"]);
if (!yearAmount.ContainsKey(year))
yearAmount[year] = 0;
yearAmount[year] += amount;
}
if (yearAmount.Count >= 2)
{
var years = yearAmount.Keys.OrderBy(y => y).ToList();
double firstYearAmount = yearAmount[years[0]];
double yeniYilCiro = yearAmount[years[1]];
if (firstYearAmount != 0)
{
double ratio = ((yeniYilCiro - firstYearAmount) / firstYearAmount) ;
e.CustomValue = ratio;
}
else
{
e.CustomValue = null;
}
}
else
{
e.CustomValue = null;
}
}
< /code>
I’ve also attached a screenshot for better understanding.

Environment Details:
- DevExpress Version: 24.1
- Platform: WinForms Pivotgrid