Stay organized with collections Save and categorize content based on your preferences.
DataSourcePivotTableAccess and modify existing data source pivot table. To create a new data source pivot table, use Range.createDataSourcePivotTable(dataSource)
.
Only use this class with data that's connected to a database.
Detailed documentationaddColumnGroup(columnName)
Adds a new pivot column group based on the specified data source column.
Parameters Name Type DescriptioncolumnName
String
The data source column name the pivot group is based on. Return
PivotGroup
— The new pivot group.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
addFilter(columnName, filterCriteria)
Adds a new filter based on the specified data source column with the specified filter criteria.
Parameters Name Type DescriptioncolumnName
String
The data source column name the filter is based on. filterCriteria
FilterCriteria
The criteria the filter uses. Return
PivotFilter
— The new filter.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
addPivotValue(columnName)
Adds a new pivot value based on the specified data source column without any summarize function. For Looker measures only.
The following code shows how you can add a Looker measure as a pivot value.
// TODO(developer): Replace with your spreadsheet ID which has a Looker data // source. const spreadsheet = SpreadsheetApp.openById('abcd1234'); const datasource = spreadsheet.getDataSources()[0]; const pivotTable = datasource.createDataSourcePivotTableOnNewSheet(); pivotTable.addPivotValue('columnName');
This method is only available for Looker data sources.
Parameters Name Type DescriptioncolumnName
String
The data source column name the pivot value is based on. Return
PivotValue
— The new pivot value.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
addPivotValue(columnName, summarizeFunction)
Adds a new pivot value based on the specified data source column with the specified summarize function.
In order to add pivot values for Looker measures, use addPivotValue(columnName)
.
columnName
String
The data source column name the pivot value is based on. summarizeFunction
PivotTableSummarizeFunction
The summarize function the pivot value uses. Return
PivotValue
— The new pivot value.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
addRowGroup(columnName)
Adds a new pivot row group based on the specified data source column.
Parameters Name Type DescriptioncolumnName
String
The data source column name the pivot group is based on. Return
PivotGroup
— The new pivot group.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
asPivotTable()
Returns the data source pivot table as a regular pivot table object.
ReturnPivotTable
— The pivot table.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
cancelDataRefresh()
Cancels the data refresh associated with this object if it's currently running.
This example shows how to cancel a formula refresh.
const spreadsheet = SpreadsheetApp.getActive(); const formula = spreadsheet.getDataSourceFormulas()[0]; // Cancel the ongoing refresh on the formula. formula.cancelDataRefresh();
Throws an exception if the data source type is not enabled. Use SpreadsheetApp#enable...Execution()
methods to enable data execution for specific data source type.
DataSourcePivotTable
— The data object.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
forceRefreshData()
Refreshes the data of this object regardless of the current state. See refreshData()
for more details. If you want to cancel a currently running refresh of this object, see cancelDataRefresh()
.
Throws an exception if the data source type is not enabled. Use SpreadsheetApp#enable...Execution()
methods to enable data execution for specific data source type.
DataSourcePivotTable
— The data object.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
getDataSource()
Gets the data source the object is linked to.
ReturnDataSource
— The data source.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
getStatus()
Gets the data execution status of the object.
ReturnDataExecutionStatus
— The data execution status.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
refreshData()
Refreshes the data of the object.
Throws an exception if currently in error
state. Use DataSource#updateSpec()
to update the specification. The method is preferred over forceRefreshData()
to prevent unexpected edits on data source.
Throws an exception if the data source type is not enabled. Use SpreadsheetApp#enable...Execution()
methods to enable data execution for specific data source type.
DataSourcePivotTable
— The data object.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
waitForCompletion(timeoutInSeconds)
Waits until the current execution completes, timing out after the provided number of seconds. Throws an exception if the execution is not completed when timing out, but does not cancel the data execution.
Parameters Name Type DescriptiontimeoutInSeconds
Integer
The time to wait for data execution, in seconds. The maximum is 300 seconds. Return
DataExecutionStatus
— The data execution status.
Scripts that use this method require authorization with one or more of the following scopes:
https://www.googleapis.com/auth/spreadsheets.currentonly
https://www.googleapis.com/auth/spreadsheets
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-03 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-03 UTC."],[[["`DataSourcePivotTable` objects allow you to programmatically access and modify existing pivot tables connected to a database."],["You can add filters, groups, and values to the pivot table using specific methods like `addColumnGroup`, `addFilter`, and `addPivotValue`."],["Data refresh can be managed with methods such as `refreshData`, `forceRefreshData`, and `cancelDataRefresh`, providing control over data updates."],["The `asPivotTable` method converts a `DataSourcePivotTable` into a regular `PivotTable` object for further manipulation."],["This class is exclusively for use with data linked to a database, ensuring that your pivot table is dynamically connected to your data source."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4