Unplanned
Last Updated: 22 May 2026 10:59 by ADMIN
Garrett
Created on: 21 May 2026 18:37
Category: UI for ASP.NET Core
Type: Bug Report
1
When using PivotGridV2 with local flat data and defining multiple measures that each reference a different numeric field, all measures resolve to the same aggregated value
**Title:**

> PivotGridV2 local flat-data binding produces identical values for all measures when multiple field-based measures are defined

---

**Description:**

When using **PivotGridV2** with local flat data (`.BindTo()` / inline `data` option) and defining **multiple measures that each reference a different numeric field**, all measures resolve to the same aggregated value instead of summing only their designated field.

### Environment
- Telerik UI for ASP.NET Core (2025 Q2 / latest)
- .NET 10
- Tested in Chrome, Edge

### Steps to Reproduce

1. Define a flat data model with multiple numeric properties:

```csharp
public class PivotRow
{
    public string Category { get; set; }
    public int Revenue { get; set; }
    public int Units { get; set; }
}
```

2. Configure PivotGridV2 with two measures on separate fields:

```csharp
.Schema(schema => schema
    .Cube(cube => cube
        .Dimensions(d => { d.Add(m => m.Category).Caption("Category"); })
        .Measures(measures =>
        {
            measures.Add("Total Revenue").Field(m => m.Revenue).AggregateName("sum");
            measures.Add("Total Units").Field(m => m.Units).AggregateName("sum");
        })
    )
)
.Measures(measures => measures.Values("Total Revenue", "Total Units"))
```

3. Bind to local data containing rows where Revenue ≠ Units (e.g., Revenue=5000, Units=3).

### Expected Behavior

Each measure column aggregates **only its own field**:
- "Total Revenue" sums only the `Revenue` property
- "Total Units" sums only the `Units` property

### Actual Behavior

**All measure columns display the same value.** Both "Total Revenue" and "Total Units" show the same number. The pivot engine appears to ignore the `field` property on each measure definition during aggregation, summing the same (first?) numeric field for every measure.

### Key Observations

- The serialized cube schema is correct — each measure has the proper `field` mapping:
  ```json
  {
    "Total Revenue": { "field": "Revenue", "aggregate": "sum" },
    "Total Units": { "field": "Units", "aggregate": "sum" }
  }
  ```
- The underlying `PivotCubeBuilder.process()` method (used by `PivotDataSource` v1) **does** produce correct per-measure values when invoked manually with the same data and configuration.
- The bug is specific to **`PivotDataSourceV2`** — the v2 pipeline does not pass the per-measure field context through to its internal aggregation path, causing all measures to resolve identically.
- A single measure (e.g., only "Total Revenue") works correctly. The bug only manifests with **2+ measures referencing different fields**.

### Workaround

We implemented a monkey-patch on `PivotDataSourceV2.fn._saveState` that intercepts the rendered cell array and recalculates each cell's value from raw data using the measure's `field` property and tuple member filters. This confirms the issue is isolated to the v2 data source aggregation pipeline — the grid rendering layer correctly displays whatever values `_saveState` provides.

### Attached

Full `.cshtml` page demonstrating the issue (with workaround patch included for reference).

Attached Files:
0 comments