Class: Google::Apis::SheetsV4::PivotGroupRule
- Inherits:
-
Object
- Object
- Google::Apis::SheetsV4::PivotGroupRule
- Includes:
- Core::Hashable, Core::JsonObjectSupport
- Defined in:
- generated/google/apis/sheets_v4/classes.rb,
generated/google/apis/sheets_v4/representations.rb,
generated/google/apis/sheets_v4/representations.rb
Overview
An optional setting on a PivotGroup that defines buckets for the values in the source data column rather than breaking out each individual value. Only one PivotGroup with a group rule may be added for each column in the source data, though on any given column you may add both a PivotGroup that has a rule and a PivotGroup that does not.
Instance Attribute Summary collapse
-
#histogram_rule ⇒ Google::Apis::SheetsV4::HistogramRule
Allows you to organize the numeric values in a source data column into buckets of a constant size.
-
#manual_rule ⇒ Google::Apis::SheetsV4::ManualRule
Allows you to manually organize the values in a source data column into buckets with names of your choosing.
Instance Method Summary collapse
-
#initialize(**args) ⇒ PivotGroupRule
constructor
A new instance of PivotGroupRule.
-
#update!(**args) ⇒ Object
Update properties of this object.
Methods included from Core::JsonObjectSupport
Methods included from Core::Hashable
Constructor Details
#initialize(**args) ⇒ PivotGroupRule
Returns a new instance of PivotGroupRule
6167 6168 6169 |
# File 'generated/google/apis/sheets_v4/classes.rb', line 6167 def initialize(**args) update!(**args) end |
Instance Attribute Details
#histogram_rule ⇒ Google::Apis::SheetsV4::HistogramRule
Allows you to organize the numeric values in a source data column into
buckets of a constant size. All values from HistogramRule.start to
HistogramRule.end will be placed into groups of size
HistogramRule.interval. In addition, all values below
HistogramRule.start will be placed in one group, and all values above
HistogramRule.end will be placed in another. Only
HistogramRule.interval is required, though if HistogramRule.start
and HistogramRule.end are both provided, HistogramRule.start must
be less than HistogramRule.end. For example, a pivot table showing
average purchase amount by age that has 50+ rows:
+-----+-------------------+
| Age | AVERAGE of Amount |
+-----+-------------------+
| 16 | $27.13 |
| 17 | $5.24 |
| 18 | $20.15 |
...
+-----+-------------------+
could be turned into a pivot table that looks like the one below by
applying a histogram group rule with a HistogramRule.start of 25,
an HistogramRule.interval of 20, and an HistogramRule.end
of 65.
+-------------+-------------------+
| Grouped Age | AVERAGE of Amount |
+-------------+-------------------+
| < 25 | $19.34 |
| 25-45 | $31.43 |
| 45-65 | $35.87 |
| > 65 | $27.55 |
+-------------+-------------------+
| Grand Total | $29.12 |
+-------------+-------------------+
Corresponds to the JSON property histogramRule
6137 6138 6139 |
# File 'generated/google/apis/sheets_v4/classes.rb', line 6137 def histogram_rule @histogram_rule end |
#manual_rule ⇒ Google::Apis::SheetsV4::ManualRule
Allows you to manually organize the values in a source data column into
buckets with names of your choosing. For example, a pivot table that
aggregates population by state:
+-------+-------------------+
| State | SUM of Population |
+-------+-------------------+
| AK | 0.7 |
| AL | 4.8 |
| AR | 2.9 |
...
+-------+-------------------+
could be turned into a pivot table that aggregates population by time zone
by providing a list of groups (e.g. groupName = 'Central',
items = ['AL', 'AR', 'IA', ...]) to a manual group rule.
Note that a similar effect could be achieved by adding a time zone column
to the source data and adjusting the pivot table.
+-----------+-------------------+
| Time Zone | SUM of Population |
+-----------+-------------------+
| Central | 106.3 |
| Eastern | 151.9 |
| Mountain | 17.4 |
...
+-----------+-------------------+
Corresponds to the JSON property manualRule
6165 6166 6167 |
# File 'generated/google/apis/sheets_v4/classes.rb', line 6165 def manual_rule @manual_rule end |
Instance Method Details
#update!(**args) ⇒ Object
Update properties of this object
6172 6173 6174 6175 |
# File 'generated/google/apis/sheets_v4/classes.rb', line 6172 def update!(**args) @histogram_rule = args[:histogram_rule] if args.key?(:histogram_rule) @manual_rule = args[:manual_rule] if args.key?(:manual_rule) end |