Class: Google::Apis::SheetsV4::PivotGroupRule

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Methods included from Core::JsonObjectSupport

#to_json

Methods included from Core::Hashable

process_value, #to_h

Constructor Details

#initialize(**args) ⇒ PivotGroupRule

Returns a new instance of PivotGroupRule



6176
6177
6178
# File 'generated/google/apis/sheets_v4/classes.rb', line 6176

def initialize(**args)
   update!(**args)
end

Instance Attribute Details

#histogram_ruleGoogle::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



6146
6147
6148
# File 'generated/google/apis/sheets_v4/classes.rb', line 6146

def histogram_rule
  @histogram_rule
end

#manual_ruleGoogle::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



6174
6175
6176
# File 'generated/google/apis/sheets_v4/classes.rb', line 6174

def manual_rule
  @manual_rule
end

Instance Method Details

#update!(**args) ⇒ Object

Update properties of this object



6181
6182
6183
6184
# File 'generated/google/apis/sheets_v4/classes.rb', line 6181

def update!(**args)
  @histogram_rule = args[:histogram_rule] if args.key?(:histogram_rule)
  @manual_rule = args[:manual_rule] if args.key?(:manual_rule)
end