title: How to Create Further Filters using App Script
body: <p>I have been trying to filtering the columns using Google Apps Script but i am unable to get that how the filter will work for second criteria.</p>
  <p>I want to create a filter which will work for entire data validation that is available in the attached sheet.</p>
  <p>If i selected the <code>position</code> from <code>cell C2</code> <code>Head Of Product Design</code> then <code>position</code> column will be shown rows with <code>Head Of Product Design</code> and then i select the <code>Stage Name</code> from <code>cell D2</code> <code>Profile review</code>. then two filter will be created 1 for C2 and other for D2 and same goes for all.</p>
  <p>Your help will be much appreciated.</p>
  <p>However first <code>onEdit</code> is working but second is not working i do not know why. Then i need to create filters ahead. But i am stuck on second 1.</p>
  <p>Your help will be appreciated.</p>
  <p><a href="https://docs.google.com/spreadsheets/d/15i1Ep46IUYLCl7odLy0YqHVJ00Z5qG_Urtwg_n5GOd4/edit#gid=1477010803" rel="nofollow noreferrer">Sheet</a></p>
  <pre><code>function onEdit() {
    const ss = SpreadsheetApp.getActiveSpreadsheet();
    const sheet1 = ss.getSheetByName(&quot;Sheet1&quot;);
    const value = sheet1.getRange('C2').getValue();
    const range = sheet1.getRange(&quot;A5:T&quot;);
    const filter = sheet1.getFilter();
    if (filter) {
      filter.remove();
    }
    range.createFilter().setColumnFilterCriteria(2, SpreadsheetApp.newFilterCriteria().whenTextContains(value).build());
  }
  
  function onEdit2() {
    const ss = SpreadsheetApp.getActiveSpreadsheet();
    const sheet1 = ss.getSheetByName(&quot;Sheet1&quot;);
    const value = sheet1.getRange('D2').getValue();
    const range = sheet1.getRange(&quot;A5:T&quot;);
    const filter = sheet1.getFilter();
    if (filter) {
      filter.remove();
    }
    range.createFilter().setColumnFilterCriteria(4, SpreadsheetApp.newFilterCriteria().whenTextContains(value).build());
  }
  </code></pre>