Data Compression in ASP.NET MVC Pivot Table

23 Aug 20261 minute to read

This property is applicable only for the relational data source.

When binding large volumes of raw data, the pivot table processes all raw data to generate aggregated data during initial rendering and report manipulation. However, with data compression enabled, the input raw data is compressed based on its unique values, and the pivot table uses the final compressed raw data. The compressed raw data is then used for all subsequent operations, reducing the looping complexity and improving the performance of the pivot table. For example, if the pivot table connects to one million raw data records that compress to 1,000 unique raw data records, it will render significantly faster—potentially within 3 seconds rather than 10 seconds, depending on the data complexity and system performance. Enable this option by setting the AllowDataCompression property to true on the Pivot Table component.

@using Syncfusion.EJ2.PivotView

@Html.EJS().PivotView("PivotView").Height(300).Width(800).DataSourceSettings(dataSource => dataSource.DataSource((IEnumerable<object>)ViewBag.DataSource).ExpandAll(true)
.Rows(rows =>
{
    rows.Name("Country").Add(); rows.Name("Products").Add();
}).Columns(columns =>
{
    columns.Name("Year").Caption("Year").Add(); columns.Name("Quarter").Add();
}).Values(values =>
{
    values.Name("Sold").Caption("Units Sold").Add(); values.Name("Amount").Caption("Sold Amount").Add();
})).EnableVirtualization(true).AllowDataCompression(true).Render()
public ActionResult Index()
{
    var data = GetPivotData();
    ViewBag.DataSource = data;
    return View();
}

Limitations during data compression:

  • The following aggregation types are not supported:
    • Average
    • PopulationStDev
    • SampleStDev
    • PopulationVar
    • SampleVar
  • If any of the above aggregation types are used, they will be automatically converted to “Sum” aggregation.
  • “DistinctCount” will function as “Count” aggregation type.
  • In a calculated field, existing fields can be inserted without changing their default aggregation type. Even if the aggregation type is changed, it will revert to the default aggregation type for calculation purposes.