Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

155
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda