is an option of PivotTable that specifies whether to add rows and columns with group aggregates.
IncludeGroupAggregates
is an option of PivotTable that specifies whether to add rows and columns with group aggregates.
Details
- IncludeGroupAggregates is typically used to add new rows and columns combining the tabular data content.
- With the default setting IncludeGroupAggregatesFalse, aggregation summaries are not included.
- With the setting IncludeGroupAggregatesTrue, PivotTable returns a Tabular object with additional rows and columns with key All or ExtendedKey[…,All], containing aggregated information about groups of rows and columns.
Examples
open all close allBasic Examples (1)
Take tabular data containing four columns:
tab = Tabular[Association["RawSchema" -> Association["ColumnProperties" ->
Association["class" -> Association["ElementType" -> "String"],
"age" -> Association["ElementType" -> "Integer64"],
"sex" -> Association["ElementType" -> "String"], "survived" ->
Association["ElementType" -> "Boolean"]], "KeyColumns" -> None,
"Backend" -> "WolframKernel"], "BackendData" ->
Association["ColumnData" -> DataStructure["ColumnTable",
{{TabularColumn[Association["Data" -> {{3, {0, 3, 6, 9, 12, 15, 18}, "1st2nd1st2nd2nd1st"},
{}, None}, "ElementType" -> "String"]], TabularColumn[
Association["Data" -> {{32, 40, 40, 20, 50, 63}, {}, None}, "ElementType" ->
"Integer64"]], TabularColumn[Association["Data" -> {{3, {0, 4, 8, 14, 20, 24, 30},
"malemalefemalefemalemalefemale"}, {}, None}, "ElementType" -> "String"]],
TabularColumn[Association["Data" -> {DataStructure["BitVector",
{"Data" -> ByteArray["DQ=="], "Capacity" -> 6}], {}, None},
"ElementType" -> "Boolean"]]}}]]]];Compute the mean age per "sex" and "class" groups, ignoring the "survived" column:
PivotTable[tab, {"mean age" -> (Mean[#age]&)}, "sex", "class"]Include group aggregates for each column and each row:
PivotTable[tab, {"mean age" -> (Mean[#age]&)}, "sex", "class", IncludeGroupAggregates -> True]Scope (1)
Make a pivot table showing the percent survival for the Titanic:
titanic = ResourceData["Sample Tabular Data: Titanic"]By default, PivotTable does not add group summaries:
PivotTable[titanic, PercentForm[Mean[Boole[#survived]]]&, "class", "sex"]Show group summaries, with a row and a column of key All:
PivotTable[titanic, PercentForm[Mean[Boole[#survived]]]&, "class", "sex", IncludeGroupAggregates -> True]Applications (1)
The data contains information on kidney transplant patients—time in days to death or on-study time since transplant at the given age:
transplants = Tabular[ResourceData["Sample Data: Kidney Transplant"]]Use the PivotTable to compute the patients' mean survival time in years split according to alive status versus gender and race, including the summary groups:
PivotTable[transplants, UnitConvert[Mean[#Time], "Years"]&, {"Gender", "Race"}, "Delta", IncludeGroupAggregates -> True]See Also
Related Guides
History
Text
Wolfram Research (2025), IncludeGroupAggregates, Wolfram Language function, https://reference.wolfram.com/language/ref/IncludeGroupAggregates.html.
CMS
Wolfram Language. 2025. "IncludeGroupAggregates." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/IncludeGroupAggregates.html.
APA
Wolfram Language. (2025). IncludeGroupAggregates. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/IncludeGroupAggregates.html
BibTeX
@misc{reference.wolfram_2026_includegroupaggregates, author="Wolfram Research", title="{IncludeGroupAggregates}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/IncludeGroupAggregates.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_includegroupaggregates, organization={Wolfram Research}, title={IncludeGroupAggregates}, year={2025}, url={https://reference.wolfram.com/language/ref/IncludeGroupAggregates.html}, note=[Accessed: 13-June-2026]}