Skip to content

Commit 0c8e359

Browse files
authored
(DOCSP-11753) Document aggregation options (#413)
* (DOCSP-11753) Document aggregation options
1 parent a022898 commit 0c8e359

File tree

3 files changed

+127
-8
lines changed

3 files changed

+127
-8
lines changed

config/sphinx_local.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ theme:
2626
- /chart-type-reference/choropleth
2727
- /chart-type-reference/grid-charts
2828
- /chart-type-reference/circular-charts
29+
- /encoding-channels
2930
- /customize-charts
3031
- /embedding-charts
3132
- /view-export-chart-data

source/encoding-channels.txt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ data). The following table describes each encoding channel type in
5858

5959
* - Aggregation
6060
- A point on the chart is created by applying an
61-
:manual:`aggregation <aggregation>` function over the values of
61+
:manual:`aggregation </aggregation>` function over the values of
6262
this field from multiple documents. For more
63-
information on aggregation in |charts-short|, see the
64-
:ref:`Aggregation <building-charts-aggregation>` section.
63+
information on using aggregation functions in |charts-short|, see
64+
:ref:`Aggregation Options <aggregation-options>`.
6565

6666
* - Geopoint
6767
- When you create a chart using a geopoint channel type, |charts|
@@ -87,11 +87,10 @@ Aggregation
8787
Dragging a field onto an :guilabel:`aggregation`
8888
:ref:`encoding channel <encoding-channels>` allows you to use an
8989
:manual:`aggregation pipeline operator </reference/operator/aggregation/>`
90-
on that field. The aggregation operators available in the chart
91-
builder change based on the :manual:`data type </reference/bson-types/>`
92-
of the selected field. MongoDB Charts categorizes the field data type
93-
as either a ``number``, ``string``, or ``date`` and displays
94-
appropriate aggregation options accordingly.
90+
on that field.
91+
92+
For a list of the available aggregation pipeline operators in
93+
|charts-short|, see :ref:`Aggregation Options <aggregation-options>`.
9594

9695
.. example::
9796

@@ -204,3 +203,10 @@ fields in the same subdocument, |charts| also adds those fields in
204203
italics. Once you add a field, you can include it in your chart,
205204
:doc:`convert its data type </convert-field-data-types>`, or
206205
:ref:`remove it <remove-calculated-field>`.
206+
207+
.. class:: hidden
208+
209+
.. toctree::
210+
:titlesonly:
211+
212+
/encoding-channels/aggregation-options
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
.. _aggregation-options:
2+
3+
===================
4+
Aggregation Options
5+
===================
6+
7+
.. default-domain:: mongodb
8+
9+
.. contents:: On this page
10+
:local:
11+
:backlinks: none
12+
:depth: 1
13+
:class: singlecol
14+
15+
Dragging a field onto an :guilabel:`aggregation`
16+
:ref:`encoding channel <encoding-channels>` allows you to use an
17+
:manual:`aggregation pipeline operator </reference/operator/aggregation/>`
18+
on that field.
19+
20+
The aggregation pipeline operators available in the chart
21+
builder change based on the :manual:`data type </reference/bson-types/>`
22+
of the selected field. MongoDB Charts categorizes the field data type
23+
as either a ``number``, ``string``, or ``date`` and displays
24+
appropriate aggregation options accordingly.
25+
26+
The following tables list the available aggregation options for each
27+
data type:
28+
29+
Numbers
30+
-------
31+
32+
.. list-table::
33+
:header-rows: 1
34+
:stub-columns: 1
35+
:widths: 20 40 40
36+
37+
* - Aggregation Option
38+
- Description
39+
- Pipeline Operation
40+
41+
* - ``sum``
42+
- Sums all values in the field.
43+
- :manual:`$sum </reference/operator/aggregation/sum/>`
44+
45+
* - ``count``
46+
- Counts the number of documents with a value in the field.
47+
- :manual:`$count </reference/operator/aggregation/count/>`
48+
49+
* - ``distinct``
50+
- Counts the number of unique values in the field.
51+
- Applies
52+
:manual:`$addToSet </reference/operator/aggregation/addToSet/>`
53+
and counts the number of items in the result set with
54+
:manual:`$size </reference/operator/aggregation/size/>`.
55+
56+
* - ``mean``
57+
- Averages all values in the field.
58+
- :manual:`$avg </reference/operator/aggregation/avg/>`
59+
60+
* - ``min``
61+
- Returns the minimum value in the field.
62+
- :manual:`$min </reference/operator/aggregation/min/>`
63+
64+
* - ``max``
65+
- Returns the minimum value in the field.
66+
- :manual:`$max </reference/operator/aggregation/max/>`
67+
68+
* - ``variance``
69+
- Calculates the sample variance of values in the field.
70+
- Applies
71+
:manual:`$stdDevSamp </reference/operator/aggregation/stdDevSamp/>`
72+
and raises the result to the 2nd power with
73+
:manual:`$pow </reference/operator/aggregation/pow/>`.
74+
75+
* - ``variancep``
76+
- Calculates the population variance of values in the field.
77+
- Applies
78+
:manual:`$stdDevPop </reference/operator/aggregation/stdDevPop/>`
79+
and raises the result to the 2nd power with
80+
:manual:`$pow </reference/operator/aggregation/pow/>`.
81+
82+
* - ``stdev``
83+
- Calculates the sample standard deviation of values in the field.
84+
- :manual:`$stdDevSamp </reference/operator/aggregation/stdDevSamp/>`
85+
86+
* - ``stdevp``
87+
- Calculates the population standard deviation of values in the
88+
field.
89+
- :manual:`$stdDevPop </reference/operator/aggregation/stdDevPop/>`
90+
91+
Strings and Dates
92+
-----------------
93+
94+
.. list-table::
95+
:header-rows: 1
96+
:stub-columns: 1
97+
:widths: 20 40 40
98+
99+
* - Aggregation Option
100+
- Description
101+
- Pipeline Operation
102+
103+
* - ``count``
104+
- Counts the number of documents with a value in the field.
105+
- :manual:`$count </reference/operator/aggregation/count/>`
106+
107+
* - ``distinct``
108+
- Counts the number of unique values in the field.
109+
- Applies the
110+
:manual:`$addToSet </reference/operator/aggregation/addToSet/>`
111+
operator and counts the number of items in the result set with
112+
:manual:`$size </reference/operator/aggregation/size/>`.

0 commit comments

Comments
 (0)