Apps Scriptリファレンス: Apps Script Reference |障害・課題追跡: IssueTracker |Google Workspace: Status Dashboard - Summary

2018年10月17日水曜日

PivotTableのFilterをスクリプトで設定したい


こういうシートがあって

こういうピボットテーブルを作って

ランチをラーメンでフィルタしてみる



コード.gs
function setFilter() {
  var ss = SpreadsheetApp.getActiveSpreadsheet()
  var sheet = ss.getSheetByName('ピボット テーブル 1')
  var pivotTable = sheet.getPivotTables()
  var setDate = SpreadsheetApp.newFilterCriteria().setVisibleValues(['ラーメン'])
  pivotTable[0].getFilters()[0].setFilterCriteria(setDate)
}



実行結果

 setFilter()を実行するとこうなる


参考

Class PivotTable
https://developers.google.com/apps-script/reference/spreadsheet/pivot-table

Class FilterCriteria
https://developers.google.com/apps-script/reference/spreadsheet/filter-criteria

Latest post

Google Workspace Business版でプロフィール画像を変更できるようにしたい

Google Workspace Business版でプロフィール画像を設定後、画像を変えられない場合 Admin console のDirectory の中にある Profile Picture をチェックしてみる Adminアカウントで  https://admin.goog...