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

Inherits:
Object
  • Object
show all
Includes:
Core::Hashable, Core::JsonObjectSupport
Defined in:
lib/google/apis/sheets_v4/classes.rb,
lib/google/apis/sheets_v4/representations.rb,
lib/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

Constructor Details

#initialize(**args) ⇒ PivotGroupRule

Returns a new instance of PivotGroupRule.



7478
7479
7480
# File 'lib/google/apis/sheets_v4/classes.rb', line 7478

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

Instance Attribute Details

#date_time_ruleGoogle::Apis::SheetsV4::DateTimeRule

Allows you to organize the date-time values in a source data column into buckets based on selected parts of their date or time values. For example, consider a pivot table showing sales transactions by date: +----------+-------- ------+ | Date | SUM of Sales | +----------+--------------+ | 1/1/2017 | $621. 14 | | 2/3/2017 | $708.84 | | 5/8/2017 | $326.84 | ... +----------+------------ --+ Applying a date-time group rule with a DateTimeRuleType of YEAR_MONTH results in the following pivot table. +--------------+--------------+ | Grouped Date | SUM of Sales | +--------------+--------------+ | 2017-Jan | $53, 731.78 | | 2017-Feb | $83,475.32 | | 2017-Mar | $94,385.05 | ... +------------- -+--------------+ Corresponds to the JSON property dateTimeRule



7439
7440
7441
# File 'lib/google/apis/sheets_v4/classes.rb', line 7439

def date_time_rule
  @date_time_rule
end

#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 are placed into groups of size HistogramRule.interval. In addition, all values below HistogramRule.start are placed in one group, and all values above HistogramRule.end are 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



7460
7461
7462
# File 'lib/google/apis/sheets_v4/classes.rb', line 7460

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 (for example, 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


7476
7477
7478
# File 'lib/google/apis/sheets_v4/classes.rb', line 7476

def manual_rule
  @manual_rule
end

Instance Method Details

#update!(**args) ⇒ Object

Update properties of this object



7483
7484
7485
7486
7487
# File 'lib/google/apis/sheets_v4/classes.rb', line 7483

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