Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

153
Views
Create a Custom Filter view in Google Sheets using App Scripts

I have a list of values in column A in a Google sheet. I'm attempting to write a script that will create a filter view for each unique value in the column.

I've written the below code, however I create a list of filter views for every value in the column rather than each unique value.

Is there a better way to write the script? How can I limit the filter views to unique values rather than every value?

function create_filter_view_test() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var ssId = ss.getId();
  var sheet1 = ss.getSheetByName("Sheet1");
  var sheetId1 = sheet1.getSheetId();
  var range1 = sheet1.getRange("A2:A" + sheet1.getLastRow());
  var values1 = range1.getValues();

  var requests =  values1.map(([a]) => ({ addFilterView: { filter: { title: a, range: { sheetId: sheetId1, startRowIndex: 0, startColumnIndex: 0 }, filterSpecs: [{ columnIndex: 0,  filterCriteria: { condition: { type: "TEXT_EQ", values: [{ userEnteredValue: a }] } } }] } } }));

  var response = Sheets.Spreadsheets.batchUpdate({ requests }, ssId);

}

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!