Pivot tables

PivotControl

Summarize rows into a cross-tab that users rearrange by dragging fields.

Overview

PivotControl is a Blazor pivot table that summarizes rows into a cross-tab, with a sum, average, count, minimum or maximum in each cell. Use it for questions such as how many airports each continent has, by type; with Interactive on, users drag fields between Filters, Rows, Columns and Values, as in an Excel PivotTable. Two row fields add subtotals, and GridControl opens the same view through AllowPivoting.

Examples

#Interactive builder

Drag fields between Filters, Rows, Columns and Values, set each value chip's aggregation and format, and click headers (Shift-click for a second key) to sort 4,009 airports.

PivotTable Fields
☐ Runway class
☐ Hemisphere
☐ Runways
☐ Longest runway (ft)
☐ Elevation (ft)
⊞ FILTERS
Drop fields here
≡ ROWS
Continent
⊞ COLUMNS
Type
Σ VALUES
Sum of Airports
Africa16417440378
Asia4176291811,227
Europe25325358564
North America1866562751,117
Oceania46193146385
South America8518865338
Grand Total1,1512,0937654,009

#Grouped rows, subtotals and two measures

Sort by airport count or longest runway with the buttons, which set SortDescriptors, and switch totals on and off; each continent closes with its own Total row.

LargeMediumSmallTotal
AirportsLongest runway (ft)
AfricaAlgeria1211,8111812,48619,8433112,486
Ethiopia412,4671111,81198,2022412,467
Nigeria1112,7941311,81102412,794
South Africa1114,4951116,07602216,076
Democratic Republic of the Congo413,1231210,49944,8232013,123
Morocco1212,205510,51101712,205
Madagascar410,17196,56231610,171
Tanzania411,811510,92577,4801611,811
Angola213,1231212,13901413,123
Egypt1213,171211,98001413,171
Kenya413,50779,19313,2811213,507
Mozambique412,008710,17115,9061212,008
Namibia215,010611,0041915,010
Spain511,22037,21814,921911,220
Cape Verde410,76024,59313,937710,760
Libya311,824312,007111,155712,007
Somalia312,139113,58239,859713,582
Sudan29,75159,880079,880
Tunisia210,499510,8270710,827
Gabon29,844310,10515,906610,105
Uganda112,000410,31413,937612,000
Zambia412,998028,858612,998
Botswana413,123016,102513,123
Cameroon311,15528,8580511,155
Equatorial Guinea310,86019,84316,177510,860
Ghana311,16525,7450511,165
Mali210,49838,8580510,498
Côte d'Ivoire19,843310,8270410,827
Zimbabwe315,50215,4130415,502
Burundi111,81113,24813,281311,811
Mauritania211,15518,2020311,155
Senegal111,48326,5730311,483
South Sudan110,17128,2020310,171
Western Sahara (disputed territory)29,84219,843039,843
Burkina Faso210,82600210,826
Comoros029,514029,514
Liberia111,00016,0000211,000
Malawi211,61400211,614
Mauritius111,05614,2230211,056
Niger110,49915,9880210,499
Republic of the Congo210,82700210,827
Réunion210,49900210,499
Rwanda111,48314,9210211,483
Saint Helena, Ascension and Tristan da Cunha0210,0190210,019
São Tomé and Principe17,28314,331027,283
Seychelles19,80014,318029,800
Benin17,9060017,906
Central African Republic18,5300018,530
Chad19,1860019,186
Djibouti110,33500110,335
Eritrea019,842019,842
Eswatini111,81100111,811
Gambia111,81100111,811
Guinea110,82600110,826
Guinea-Bissau110,49900110,499
Lesotho110,49800110,498
Mayotte16,3300016,330
Sierra Leone110,49800110,498
Togo19,8470019,847
Africa Total16415,50217416,0764011,15537816,076
AsiaChina6916,40415615,7483613,12326116,404
Indonesia1913,2185011,715528,53712113,218
India4314,5346310,3841010,41711614,534
Russia2512,3035716,404217,87410316,404
Japan2813,1235410,00012,6258313,123
Turkey1413,1233512,50304913,123
Iran1514,4252714,664311,7394514,664
Philippines1512,261247,01455,9154412,261
Malaysia813,5301811,41782,4023413,530
Thailand1013,1232310,00703313,123
Saudi Arabia1614,2221312,00502914,222
Kazakhstan1914,76429,84637,5462414,764
Myanmar314,0031412,01368,5302314,003
Pakistan1112,35389,84246,9982312,353
Vietnam812,4681211,811210,4992212,468
Nepal310,99164,937104,0001910,991
Maldives312,00049,35085,9051512,000
South Korea813,12379,30001513,123
Mongolia111,811109,35221311,811
Taiwan712,008610,00701312,008
Uzbekistan613,123613,12319,2991313,123
Bangladesh310,49958,0000810,499
United Arab Emirates714,764018,202814,764
Laos39,84318,85838,55579,843
Sri Lanka310,991411,4830711,483
Yemen410,669310,8270710,827
Afghanistan411,48318,74016,049611,483
Azerbaijan313,123211,811110,837613,123
Iraq515,748111,4810615,748
Turkmenistan312,467312,4670612,467
Cambodia413,12315,2500513,123
Greece410,846012,618510,846
Oman413,38618,2020513,386
Georgia412,01200412,012
Kyrgyzstan313,78018,2020413,780
North Korea111,490311,4820411,490
Syria211,811211,8600411,860
Tajikistan410,43300410,433
Timor-Leste27,21828,233048,233
Bhutan17,431024,15437,431
Cyprus310,49800310,498
Egypt210,108113,1230313,123
Israel213,32714,3240313,327
Jordan312,00800312,008
Armenia212,63100212,631
Qatar215,91200215,912
Singapore113,12316,0240213,123
Bahrain112,97900112,979
Brunei112,00000112,000
Christmas Island016,900016,900
Cocos (Keeling) Islands17,9990017,999
Hong Kong112,46700112,467
Kuwait115,02600115,026
Lebanon112,46700112,467
Macau110,54400110,544
Asia Total41716,40462916,40418113,1231,22716,404
EuropeUnited Kingdom1712,799239,003135,7875312,799
France1713,8292912,66434,5704913,829
Norway1011,8113010,75563,3864611,811
Russia1815,0922412,53338,2024515,092
Italy2512,861169,84304112,861
Germany2213,12378,20294,2653813,123
Sweden1110,9902310,72847,5523810,990
Greece713,1231410,997139,8953413,123
Spain1614,2711811,48303414,271
Finland1011,483108,53302011,483
Portugal512,5001310,87012,6251912,500
Romania1211,48448,16001611,484
Poland1112,10648,20201512,106
Denmark511,81159,81613,0451111,811
Ireland410,49526,56241,9681010,495
Iceland210,05667,05413,937910,056
Croatia610,66928,2020810,669
Austria611,81100611,811
Czech Republic512,18918,6940612,189
Belgium311,936212,1060512,106
Estonia111,41746,5610511,417
Netherlands512,46700512,467
Switzerland212,79535,6760512,795
Belarus212,13928,4280412,139
Bosnia and Herzegovina48,6660048,666
Bulgaria411,81100411,811
Hungary312,16218,2020412,162
Slovakia110,466310,1710410,466
Lithuania310,66300310,663
Serbia211,48317,4310311,483
Guernsey025,194025,194
Montenegro18,20218,208028,208
North Macedonia29,6780029,678
Slovenia110,82718,2020210,827
Turkey113,45119,8440213,451
Albania19,8430019,843
Faroe Islands15,9050015,905
Gibraltar16,0000016,000
Isle of Man16,9230016,923
Jersey015,594015,594
Kosovo19,9740019,974
Latvia110,49900110,499
Luxembourg113,12300113,123
Malta110,99100110,991
Moldova111,77800111,778
Europe Total25315,09225312,664589,89556415,092
North AmericaUnited States9116,00040113,50213115,00062316,000
Canada1514,00012212,0001156,00025214,000
Mexico2914,7643010,17148,2026314,764
Bahamas311,353198,02402211,353
Cuba613,13099,86901513,130
Greenland17,21789,21942,953139,219
Belize19,67872,19842,372129,678
Panama110,00668,85858,5001210,006
Costa Rica29,88275,906099,882
Dominican Republic411,000410,1080811,000
Honduras39,20339,875289,875
Puerto Rico110,002711,7020811,702
Guatemala19,80039,84226,90069,842
Guadeloupe111,49914,06831,985511,499
Saint Vincent and the Grenadines19,00045,900059,000
Turks and Caicos Islands19,19936,362159,199
Haiti29,97423,220049,974
Jamaica210,03924,7690410,039
Nicaragua18,01228,13016,23448,130
Caribbean Netherlands19,44924,265039,449
Antigua and Barbuda19,00316,100029,003
British Virgin Islands14,64213,100024,642
Cayman Islands17,86716,000027,867
Colombia17,80813,832027,808
Dominica026,352026,352
El Salvador110,50017,3490210,500
Grenada19,003012,62529,003
Saint Kitts and Nevis17,60213,996027,602
Saint Lucia19,00315,735029,003
Saint Pierre and Miquelon015,90613,28025,906
Trinidad and Tobago210,50000210,500
U.S. Virgin Islands17,000110,0020210,002
Venezuela110,433012,756210,433
Anguilla015,462015,462
Aruba19,0000019,000
Barbados111,00000111,000
Bermuda19,7050019,705
Curaçao111,18800111,188
Martinique19,8430019,843
Montserrat11,9680011,968
Saint Barthélemy012,119012,119
Saint Martin013,937013,937
Sint Maarten17,5460017,546
North America Total18616,00065613,50227515,0001,11716,000
OceaniaAustralia1512,99910010,771408,20215512,999
French Polynesia111,3602411,089134,5923811,360
Papua New Guinea29,022197,185165,774379,022
New Zealand411,926227,25123,0512811,926
Solomon Islands17,21814,593185,413207,218
Fiji210,73913,507144,8061710,739
Vanuatu18,53026,523142,972178,530
Marshall Islands17,89716,668147,700167,897
New Caledonia110,66384,10123,6161110,663
United States412,36069,80012,7001112,360
Cook Islands17,638055,92067,638
Tonga28,79513,93722,65058,795
Kiribati26,9000246,900
Micronesia36,00616,600046,600
American Samoa110,000023,190310,000
Northern Mariana Islands16,00028,700038,700
Wallis and Futuna16,890013,60926,890
Guam112,01500112,015
Nauru017,054017,054
Niue017,660017,660
Norfolk Island016,398016,398
Palau17,2000017,200
Samoa19,8430019,843
Tuvalu015,040015,040
United States Minor Outlying Islands019,843019,843
Oceania Total4612,99919311,0891468,20238512,999
South AmericaBrazil2813,123639,055388,36612913,123
Colombia512,467358,44885,6434812,467
Argentina1311,4832910,82736,3404511,483
Peru813,7801611,48218,2022513,780
Venezuela611,4831310,64513,9372011,483
Chile812,30399,97426,5621912,303
Bolivia613,123710,00734,9211613,123
Ecuador413,445812,11736,7251513,445
Suriname111,417053,934611,417
Guyana111,02335,9850411,023
French Guiana110,48623,9380310,486
Paraguay311,15400311,154
Uruguay110,49926,9980310,499
Falkland Islands018,49713,01328,497
South America Total8513,78018812,117658,36633813,780
Grand Total1,15116,4042,09316,40476515,0004,00916,404

Sort: __Total_Code_Count Descending.

#Formula columns in a grid

Elevation (m) is a column Formula, [ElevationFt] * 0.3048, worked out per row; Longest runway (km) holds cell values that start with =, evaluated because AllowCellFormulas is on.

Code City Country Elevation (ft) Elevation (m) Longest runway (ft) Longest runway (km)
AMSAmsterdamNetherlands-11-312,4673.80
LHRLondonUnited Kingdom832512,7993.90
LISLisbonPortugal37411412,5003.81
KEFReykjavíkIceland1715210,0563.07
DXBDubaiUnited Arab Emirates621914,5904.45
HNDTokyoJapan351111,0243.36
SYDSydney (Mascot)Australia21612,9993.96
DENDenverUnited States5,4311,65516,0004.88
JNBJohannesburgSouth Africa5,5581,69414,4954.42
MEXMexico CityMexico7,3162,23012,9663.95
BOGBogotaColombia8,3612,54812,4673.80
LPBLa Paz / El AltoBolivia13,3554,07113,1234.00

Documentation

ParameterTypeDefaultDescription
DataSourceIEnumerable<TValue>Enumerable.Empty<TValue>()The rows to aggregate. A field is read by property name, case-insensitive, or by key when the rows are IDictionary<string, object>.
RowFieldsIReadOnlyList<string>Array.Empty<string>()Fields that label the rows, outermost first. With two or more, the first spans its group and a subtotal row closes it. With none, the table is empty.
ColumnFieldsIReadOnlyList<string>Array.Empty<string>()Fields spread across the columns. One field gives one header row, two give a grouped header above the leaves; the headers are laid out for at most two. With none, a single Value column.
ValueFieldstring""The field to aggregate when ValueFields is not set.
AggregationAggregateTypeAggregateType.SumHow ValueField is aggregated. Count counts rows; the others skip values that do not convert to a number. With nothing left, Sum prints 0 and Average, Min and Max print an empty cell.
ValueFormatstring""Format for ValueField's cells, such as N0 or C2. Blank prints the plain number without grouping.
ValueFieldsIReadOnlyList<PivotValueConfig>?nullSeveral measures, each with its own aggregation, format and label; overrides ValueField and Aggregation. With more than one, every column gets a sub-column per measure and the Total column is repeated per measure.
FieldLabelsDictionary<string, string>?nullDisplay text by field name, used in headers, chips and filter labels. A field that is not listed shows its name.
ShowSubTotalsbooltrueWith two or more row fields, adds a "group Total" row after each first-level group.
ShowGrandTotalsbooltrueAdds a Total column per measure and a Grand Total row.
AllowSortingbooltrueMakes the headers, and the chips' arrows in the builder, clickable. Sorting a row or column field reorders its values; sorting a value column orders the rows by that column's aggregate and keeps rows inside their group. A click cycles ascending, descending, off; Shift-click adds a key.
SortDescriptorsIReadOnlyList<PivotSortDescriptor>?nullSort keys set by the page, one per field; applied whenever the list differs from the one last applied. An empty list clears the sort.
InteractiveboolfalseShows the field builder: the available fields (the row type's public readable properties, or the first row's keys for dictionary rows, minus names ending in Formula), the Filters, Rows, Columns and Values zones, an aggregation dropdown and format box per measure, and a filter bar above the table. The builder is seeded from the parameters once and then keeps its own state.
Heightstring"420px"Maximum height of the scrolling table; the builder and the filter bar are outside it.
Widthstring""Maximum width of the scrolling table. Blank sets none.
CssClassstring""Added to the root element.
Stylestring""Inline style of the root element.
An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.